コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 /// <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);
     }
 }
コード例 #5
0
 /// <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);
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 /// <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;
             }
         }
     }
 }
コード例 #8
0
        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;
            }
        }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
        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));
        }
コード例 #11
0
 public PersonController()
 {
     AutomapperConfiguration.Configure();
     _personModel = new PersonnelModel();
 }
コード例 #12
0
        private void SupprimerPersonnel(object obj)
        {
            PersonnelModel p = obj as PersonnelModel;

            PersonnelService.SupprimerPersonnel(club, p);
        }
コード例 #13
0
        public PersonnelViewModel()
        {
            Model = new PersonnelModel();

            Personnel = new UserCreateDTO();
        }
コード例 #14
0
 public ModifierPersonnelModelView(ClubModel club, PersonnelModel P)
 {
     this.club = club;
     this.P    = P;
     ModifierPersonnelCommand = new SimpleCommand(ModifierPersonnel);
 }
コード例 #15
0
 public AjouterPersonnelModelView(ClubModel club)
 {
     this.club = club;
     Personnel = new PersonnelModel();
     AjouterPersonnelCommand = new SimpleCommand(AjouterPersonnel);
 }
コード例 #16
0
        public bool PutNewPersonnel(PersonnelModel data)
        {
            bool retVal = false;

            return(retVal);
        }
コード例 #17
0
 public string UpdateEmpDetails(PersonnelModel model)
 {
     return("Employee details Updated with Name " + model.Name + " and Id " + model.Id);
 }