コード例 #1
0
        public int UpdateAdminSetting(AdministratorSettingModel model)
        {
            var administratorSetting = _administratorSettingRepository.Find(x => x.CompanyID == model.CompanyID).FirstOrDefault();

            if (administratorSetting != null)
            {
                Mapper.CreateMap <AdministratorSettingModel, tblAdministratorSetting>()
                .ForMember(dest => dest.AdministratorSettingID, opt => opt.Ignore());
                tblAdministratorSetting adminsetting = (tblAdministratorSetting)Mapper.Map(model, administratorSetting);

                return(_administratorSettingRepository.SaveChanges());
            }

            return(0);
        }
コード例 #2
0
        public int SaveAdminSetting(AdministratorSettingModel model)
        {
            if (model.AssignedEmployeeID.HasValue)
            {
                if (CheckDuplicate(model.AssignedEmployeeID.Value))
                {
                    throw new Exception("Already employee assigned as administrator");
                }
            }

            model.CreatedDate = DateTime.Now;
            var administratorSetting = Mapper.DynamicMap <tblAdministratorSetting>(model);

            _administratorSettingRepository.Add(administratorSetting);
            _administratorSettingRepository.SaveChanges();

            // Update role id in employee detail table
            var employeeDetail = _employeeDetailsRepository.Get(model.AssignedEmployeeID.Value);

            employeeDetail.EmpRoleID       = 1;
            employeeDetail.LastUpdatedDate = DateTime.Now;
            employeeDetail.LastUpdatedBy   = model.LastUpdatedBy;
            return(_employeeDetailsRepository.SaveChanges());
        }
コード例 #3
0
 // PUT api/<controller>/5
 public void Put([FromBody] AdministratorSettingModel model)
 {
     model.CompanyID = CompanyId;
     _administratorSettingService.UpdateAdminSetting(model);
 }
コード例 #4
0
 // POST api/<controller>
 public void Post([FromBody] AdministratorSettingModel model)
 {
     model.CompanyID     = CompanyId;
     model.LastUpdatedBy = HttpContext.Current.User.Identity.GetUserName();
     _administratorSettingService.SaveAdminSetting(model);
 }