Exemplo n.º 1
0
        public int Save(tblHolidays_AbsenceSettingsModel model)
        {
            var holidaysAbsenceSettings = Mapper.DynamicMap <tblHolidays_AbsenceSettings>(model);

            _holidaysAbsenceSettingRepository.Add(holidaysAbsenceSettings);
            return(_holidaysAbsenceSettingRepository.SaveChanges());
        }
 // POST api/<controller>
 public void Post([FromBody] tblHolidays_AbsenceSettingsModel model)
 {
     model.CompanyID = base.CompanyId;
     if (model.Holidays_AbsenceSettingID <= 0)
     {
         _holidaysAbsenceSettingService.Save(model);
     }
     else
     {
         _holidaysAbsenceSettingService.Update(model);
     }
 }
Exemplo n.º 3
0
        public int Update(tblHolidays_AbsenceSettingsModel model)
        {
            var holidaysAbsenceSettingsEntity = _holidaysAbsenceSettingRepository.Find(x => x.Holidays_AbsenceSettingID == model.Holidays_AbsenceSettingID).FirstOrDefault();

            if (holidaysAbsenceSettingsEntity != null)
            {
                Mapper.CreateMap <tblHolidays_AbsenceSettingsModel, tblHolidays_AbsenceSettings>()
                .ForMember(dest => dest.Holidays_AbsenceSettingID, opt => opt.Ignore());     // ignore primary key while update/delete
                tblHolidays_AbsenceSettings holidaysAbsenceSettings = (tblHolidays_AbsenceSettings)Mapper.Map(model, holidaysAbsenceSettingsEntity);

                return(_holidaysAbsenceSettingRepository.SaveChanges());
            }

            return(0);
        }
 // PUT api/<controller>/5
 public void Put([FromBody] tblHolidays_AbsenceSettingsModel model)
 {
     _holidaysAbsenceSettingService.Update(model);
 }