コード例 #1
0
        private SetContactCode SetContact(UserDTO userDTO, string value, string propertyName, Func <string, IUOW, CheckResult> checkFunc, IUOW Data)
        {
            var User = GetUserService.Get(userDTO, Data);

            if (User == null)
            {
                return(SetContactCode.UserNotFound);
            }
            if (User.GetType().GetProperty(propertyName).GetValue(User) != null)
            {
                return(SetContactCode.AlreadySet);
            }
            var check = checkFunc(value, Data);

            if (check == CheckResult.AlreadyExists)
            {
                return(SetContactCode.AlreadyExists);
            }
            else if (check == CheckResult.WrongValue)
            {
                return(SetContactCode.WrongValue);
            }

            User.GetType().GetProperty(propertyName).SetValue(User, new Contact {
                Confirmed = false, Value = value
            });
            Data.UserRepository.Edited(User);
            Data.SaveChanges();
            return(SetContactCode.Succsess);
        }
コード例 #2
0
        private ConfirmResult RemoveContact(User User, string propertyName, Func <Contact, IUOW, string, ConfirmResult> func, AuthType checkType, IUOW Data, string key = null)
        {
            if (User == null)
            {
                return new ConfirmResult {
                           Status = ConfirmCode.UserNotFound
                }
            }
            ;
            var Property = User.GetType().GetProperty(propertyName);
            var Contact  = Property.GetValue(User) as Contact;

            if (Contact == null)
            {
                return new ConfirmResult {
                           Status = ConfirmCode.ContactNotFound
                }
            }
            ;
            var res = func(Contact, Data, key);

            if (res.Status == ConfirmCode.Success && User.authType == checkType)
            {
                Property.SetValue(User, null);

                User.authType = AuthType.Simple;
                Data.UserRepository.Edited(User);
                Data.SaveChanges();
            }
            return(res);
        }
コード例 #3
0
        public ActionResult CreateWord(CreateSlowoViewModel model)
        {
            Slowo slowo = new Slowo()
            {
                Zawartosc = model.Slowo,
                Jezyk     = UOW.JezykRepo.Get(model.JezykId)
            };

            UOW.SlowoRepo.Add(slowo);
            UOW.SaveChanges();
            return(RedirectToAction("Words", new { languageId = model.JezykId }));
        }
コード例 #4
0
        public Resultaten addResultaat(Resultaten resultaat)
        {
            resultaat.Datum = DateTime.Now.ToString();

            reposRes.Insert(resultaat);

            uow.SaveChanges();

            return(resultaat);
        }
コード例 #5
0
            public async Task <int> Handle(CreateProductCommand command, CancellationToken cancellationToken)
            {
                var product = new Product();

                product.Barcode     = command.Barcode;
                product.Name        = command.Name;
                product.Rate        = command.Rate;
                product.Description = command.Description;
                _unitOfWork.GetProductRepository.Create(product);
                await _unitOfWork.SaveChanges();

                return(product.Id);
            }
コード例 #6
0
 public DateTime Generate(Contact contact, IUOW Data)
 {
     if (contact == null)
     {
         throw new KeyException(KeyError.ContactNotFound);
     }
     if (contact.ConfirmKey != null)
     {
         if (contact.ConfirmKey.EndTime > DateTime.Now)
         {
             return(contact.ConfirmKey.EndTime);
         }
     }
     contact.ConfirmKey = KeyGenerator.Get();
     Data.ContactRepository.Edited(contact);
     Data.SaveChanges();
     Messager.Send(contact.Value, "Your key: " + contact.ConfirmKey.Value);
     return(contact.ConfirmKey.EndTime);
 }
コード例 #7
0
        //---------------------------------------------------
        public ClaimsIdentity Generate(User user, IUOW Data, LoginInfoDTO loginInfoDTO)
        {
            if (user == null || loginInfoDTO == null)
            {
                return(null);
            }
            var claim = GenerateClaim(user, loginInfoDTO);

            Data.UserClaimRepository.Add(claim);
            Data.SaveChanges();
            var claims = new List <Claim>
            {
                new Claim(ClaimNames.UserID, user.Id.ToString()),
                new Claim(ClaimNames.SessionID, claim.Id.ToString()),
                new Claim(ClaimNames.SessionValue, claim.Value.ToString()),
            };

            return(new ClaimsIdentity(claims, "ApplicationCookie"));
        }
コード例 #8
0
        public void RemoveAllClaims(User user, IUOW Data, params string[] without)
        {
            if (user == null)
            {
                return;
            }
            var claims = Data.UserClaimRepository.Get().Where(x => x.User == user).ToList();

            foreach (var claim in without)
            {
                var res = claims.FirstOrDefault(x => x.Value == claim);
                if (res != null)
                {
                    claims.Remove(res);
                }
            }

            Data.UserClaimRepository.Delete(claims);
            Data.SaveChanges();
        }
コード例 #9
0
 private void SetPassword(User user, string password, IUOW Data)
 {
     user.Password = PassHasher.Get(password);
     Data.UserRepository.Edited(user);
     Data.SaveChanges();
 }
コード例 #10
0
 public Leerling Updateleerling(Leerling leerling)
 {
     LeerlingRepository.Update(leerling);
     uow.SaveChanges();
     return(leerling);
 }
コード例 #11
0
 private void RemoveKey(Contact contact, IUOW Data)
 {
     Data.AuthKeyRepository.Delete(contact.ConfirmKey);
     Data.SaveChanges();
 }
コード例 #12
0
 public void SaveChanges()
 {
     UnitOfWork.SaveChanges();
 }
コード例 #13
0
 public School Voegschooltoe(School school)
 {
     SchoolRepository.Insert(school);
     uow.SaveChanges();
     return(school);
 }
コード例 #14
0
 private void ConfirmContact(Contact contact, IUOW Data)
 {
     contact.Confirmed = true;
     Data.ContactRepository.Edited(contact);
     Data.SaveChanges();
 }
コード例 #15
0
 private void RemoveContact(Contact contact, IUOW Data)
 {
     Data.ContactRepository.Delete(contact);
     Data.SaveChanges();
 }