Beispiel #1
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;
            }
        }