public void AddUserRegister(User user, Profile profile, List <UserNotes> userNotes) { //verificar se já existe o usuário var userBD = _userAppService.GetUserByEmail(user.Email); if (userBD != null) { throw new Exception("Usuário existente."); } user.Password = Encryptor.GenerateHashMd5(user.Password); user.CreateDate = DateHour.GetDateTimeServer(); _userAppService.Insert(user); profile.IdUser = user.IdUser; _profileAppService.Insert(profile); userNotes.All(c => { c.IdUser = user.IdUser; return(true); }); userNotes.All(c => { c.Note = Encryptor.Encrypt(c.Note); return(true); }); foreach (var note in userNotes) { _userNoteAppService.Insert(note); } }
public ActionResult Create(ProfileViewModel profileViewCreate) { GroupPermissions(profileViewCreate); if (!ModelState.IsValid) { return(View(profileViewCreate)); } List <string> errors = _profileAppService.Insert(profileViewCreate); if (errors?.Count > 0) { if (errors.Contains(CodLogErrorEnum.CODELOGERROR.ToString())) { this.Flash("Error", ResultMessages.AplicationException()); } else { AddModelStateError(errors); return(View(profileViewCreate)); } } else { this.Flash("Success", ResultMessages.Success()); } return(RedirectToAction("Index")); }