Esempio n. 1
0
        public int Update(tblEmployeeSettingModel model)
        {
            var employeeSettingsEntity = _employeeSettingRepository.Find(x => x.EmployeeSettingsID == model.EmployeeSettingsID).FirstOrDefault();

            if (employeeSettingsEntity != null)
            {
                Mapper.CreateMap <tblEmployeeSettingModel, tblEmployeeSetting>()
                .ForMember(dest => dest.EmployeeSettingsID, opt => opt.Ignore());     // ignore primary key while update/delete
                tblEmployeeSetting employeeSettings = (tblEmployeeSetting)Mapper.Map(model, employeeSettingsEntity);

                return(_employeeSettingRepository.SaveChanges());
            }

            return(0);
        }
Esempio n. 2
0
        public int Save(tblEmployeeSettingModel model)
        {
            // var employeeSettings = Mapper.DynamicMap<tblEmployeeSetting>(model);
            //  _employeeSettingRepository.Add(employeeSettings);
            // return _employeeSettingRepository.SaveChanges();


            var employeeSetting = _employeeSettingRepository.Find(x => x.CompanyID == model.CompanyID).FirstOrDefault();

            if (employeeSetting == null)
            {
                var employeeSettings = Mapper.DynamicMap <tblEmployeeSetting>(model);
                _employeeSettingRepository.Add(employeeSettings);
            }
            else
            {
                model.EmployeeSettingsID = employeeSetting.EmployeeSettingsID;
                Update(model);
            }
            return(_employeeSettingRepository.SaveChanges());
        }
 // PUT api/<controller>/5
 public void Put([FromBody] tblEmployeeSettingModel model)
 {
     _employeeSettingService.Update(model);
 }
 // POST api/<controller>
 public void Post([FromBody] tblEmployeeSettingModel model)
 {
     model.CompanyID = base.CompanyId;
     _employeeSettingService.Save(model);
 }