Repo_User.cs

37 lines | 945 B Blame History Raw Download
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Model.Entities.Base;
using Model.UnitsOfWork;

namespace Model.Entities.Users
{
    public class Repo_User : BaseRepository<User>
    {
        public Repo_User(UOW UOW) : base(UOW) { }

        protected override void Validation_Create(User elem)
        {
            if (All_NoTrack.FirstOrDefault(e => e.Login == elem.Login) != null)
                throw new Exception();

            if (elem.Groups.Count() == 0)
                throw new Exception();
        }

        protected override void Validation_Delete(User elem)
        {
            throw new NotImplementedException();
        }

        protected override void Validation_Update(User old, User elem)
        {
            if (All_NoTrack.FirstOrDefault(e => e.Login == elem.Login) != null)
                throw new Exception();
        }
    }
}