public ActionResponseModel Put([FromBody] PersonnelModel personnelModel) { ActionResponseModel response = new ActionResponseModel(); response.Error = new List <string>(); try { if (personnelModel.Email != null && personnelModel.Email != User.Identity.Name) { response.Error.Add("Email address is not editable"); } if (response.Error.Count > 0) { response.Success = false; } else { var personnel = _personnelService.GetByEmail(User.Identity.Name); _personnelService.Update(personnelModel.ToUpdateDBModel(personnel)); response.Success = true; } } catch (Exception ex) { response.Success = false; response.Error.Add(ex.Message); } return(response); }
public ActionResponseModel Post([FromBody] PersonnelModel personnelModel) { ActionResponseModel response = new ActionResponseModel(); response.Error = new List <string>(); try { if (_personnelService.GetByEmail(personnelModel.Email) != null || _userService.GetByEmail(personnelModel.Email) != null) { response.Error.Add("Email already used"); } if (response.Error.Count > 0) { response.Success = false; } else { var businessId = _personnelService.GetByEmail(User.Identity.Name).BusinessId; _personnelService.Create(businessId, personnelModel.ToDBModel()); response.Success = true; } } catch (Exception ex) { response.Success = false; response.Error.Add(ex.Message); } return(response); }
public async Task <IDataResponse <int> > InsertAsync(PersonnelModel model) { var entity = _mapper.Map <Personnel>(model); var password = Helper.CreatePassword(); HashingHelper.CreatePasswordHash(password, out var passwordHash, out var passwordSalt); entity.PasswordHash = passwordHash; entity.PasswordSalt = passwordSalt; entity.RefreshToken = Helper.CreateToken(); entity.RefreshTokenExpiredDate = DateTime.Now.AddDays(-1); var result = await _dal.InsertAsync(entity); if (!result.Success) { return(result); } var emailTemplate = await _emailTemplateService.GetTemplateAndEmailParameterAsync(EmailTemplateType.CreatePersonnelPasswordNotification); emailTemplate.Body = emailTemplate.Body .Replace("[Password]", password) .Replace("[FullName]", $"{model.FirstName} {model.LastName}"); var emailResult = await _emailService.SendMailAsync(model.Email, emailTemplate); return(!emailResult.Success ? new ErrorDataResponse <int>(result.Data, emailResult.Message) : result); }
/// <summary> /// Supprime une personne du personnel du club /// </summary> public static void SupprimerPersonnel(ClubModel club, PersonnelModel p) { if (club.Personnels.Contains(p)) { club.Personnels.Remove(p); } }
/// <summary> /// Ajoute une personne au personnel du club /// </summary> public static void AjouterPersonnel(ClubModel club, PersonnelModel P) { if (!club.Personnels.Contains(P)) { club.Personnels.Add(P); } }
public async Task <ResultModel <PersonnelOutputModel> > InsertPersonnel([FromForm] PersonnelInputModel item) { var result = new ResultModel <PersonnelOutputModel>(); var isDuplicateCode = await _personnelStoreService.IsDuplicateCode(item.PersonnelCode, item.Id); if (isDuplicateCode) { result.Info = new Info { Succeeded = false, InfoType = Model.Enum.InfoType.Error, Message = Model.Enum.MessageType.CodeIsNotUnique }; return(result); } var personnelItem = new PersonnelModel() { PersonnelCode = item.PersonnelCode, FirstName = item.FirstName, LastName = item.LastName, PersonnelCategoryId = item.PersonnelCategoryId, PersonnelTitleId = item.PersonnelTitleId, WorkTypeId = item.WorkTypeId }; var branches = string.IsNullOrEmpty(item.Branches) ? new int[] { } : item.Branches.Split(',').Select(int.Parse).ToArray(); using (var ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }, TransactionScopeAsyncFlowOption.Enabled)) { result = await _personnelStoreService.InsertAndSaveAsync <PersonnelOutputModel>(personnelItem); if (result.Info.Succeeded) { var file = Request != null && Request.Form != null && Request.Form.Files.Count > 0 ? Request.Form.Files[0] : null; if (file != null && file.Length > 0) { await UploadImageAsync(result.Result.Id, file); } } if (branches != null && branches.Length > 0 && result.Info.Succeeded) { await _personnelBranchStoreService.UpdatePersonelBranchAsync(result.Result.Id, branches); } ts.Complete(); } return(result); }
/// <summary> /// Modifie un personnel du club /// </summary> public static void ModifierPersonnel(ClubModel club, PersonnelModel P) { if (P != null) { foreach (PersonnelModel p in club.Personnels) { if (p.IdMembre == P.IdMembre) { club.Personnels.Remove(p); club.Personnels.Add(P); break; } } } }
public ActionResult AddPersonnel(PersonnelModel model) { try { if (Session["User"] == null) { return(RedirectToAction("Login", "Account")); } var user = (UserModel)Session["User"]; if (model != null) { var add = new PersonnelModel { CreatedDate = DateTime.Now, IsDeleted = false, CreatedById = user.UserId, Email = model.Email, LastName = model.LastName, Name = model.Name, Phone = model.Phone, }; var personnel = _personnelRepository.AddNewPersonnelByPersonnelModel(model); if (personnel != null) { var salary = new SalaryModel { IsDeleted = false, CreatedDate = DateTime.Now, CreatedById = user.UserId, Description = model.Description, Total = model.Total, PersonnelId = personnel.PersonnelId, }; var salaryAdd = _salaryRepository.AddNewSalaryBySalaryModel(salary); } } return(RedirectToAction("PersonnelList", "Personnel")); } catch (Exception) { throw; } }
public Personnel AddNewPersonnelByPersonnelModel(PersonnelModel model) { try { var add = new Personnel { IsDeleted = false, CreatedDate = model.CreatedDate, Email = model.Email, LastName = model.LastName, Name = model.Name, Phone = model.Phone, }; Add(add); Commit(); return(add); } catch (Exception) { throw; } }
public async Task <IResponse> UpdateAsync(PersonnelModel model) { var entity = await _dal.GetAsync(x => x.Id == model.Id); if (_userService.IsAdmin) { entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Gsm = model.Gsm; entity.Email = model.Email; entity.PersonnelType = model.PersonnelType; entity.RoleId = model.RoleId; entity.TitleId = model.TitleId; entity.DepartmentId = model.DepartmentId; } else { entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Gsm = model.Gsm; entity.Email = model.Email; } return(await _dal.UpdateAsync(entity)); }
public PersonController() { AutomapperConfiguration.Configure(); _personModel = new PersonnelModel(); }
private void SupprimerPersonnel(object obj) { PersonnelModel p = obj as PersonnelModel; PersonnelService.SupprimerPersonnel(club, p); }
public PersonnelViewModel() { Model = new PersonnelModel(); Personnel = new UserCreateDTO(); }
public ModifierPersonnelModelView(ClubModel club, PersonnelModel P) { this.club = club; this.P = P; ModifierPersonnelCommand = new SimpleCommand(ModifierPersonnel); }
public AjouterPersonnelModelView(ClubModel club) { this.club = club; Personnel = new PersonnelModel(); AjouterPersonnelCommand = new SimpleCommand(AjouterPersonnel); }
public bool PutNewPersonnel(PersonnelModel data) { bool retVal = false; return(retVal); }
public string UpdateEmpDetails(PersonnelModel model) { return("Employee details Updated with Name " + model.Name + " and Id " + model.Id); }