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); }
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); }
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 })); }
public Resultaten addResultaat(Resultaten resultaat) { resultaat.Datum = DateTime.Now.ToString(); reposRes.Insert(resultaat); uow.SaveChanges(); return(resultaat); }
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); }
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); }
//--------------------------------------------------- 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")); }
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(); }
private void SetPassword(User user, string password, IUOW Data) { user.Password = PassHasher.Get(password); Data.UserRepository.Edited(user); Data.SaveChanges(); }
public Leerling Updateleerling(Leerling leerling) { LeerlingRepository.Update(leerling); uow.SaveChanges(); return(leerling); }
private void RemoveKey(Contact contact, IUOW Data) { Data.AuthKeyRepository.Delete(contact.ConfirmKey); Data.SaveChanges(); }
public void SaveChanges() { UnitOfWork.SaveChanges(); }
public School Voegschooltoe(School school) { SchoolRepository.Insert(school); uow.SaveChanges(); return(school); }
private void ConfirmContact(Contact contact, IUOW Data) { contact.Confirmed = true; Data.ContactRepository.Edited(contact); Data.SaveChanges(); }
private void RemoveContact(Contact contact, IUOW Data) { Data.ContactRepository.Delete(contact); Data.SaveChanges(); }