public TMSPublicHoliday Add(TMSPublicHolidayCreateViewModel Vm) { var entity = _mapper.Map <TMSPublicHolidayCreateViewModel, TMSPublicHoliday>(Vm); _iTMSPublicHolidayRepository.Add(entity); var publicHolidayGlobal = _publicHolidayRepository.Get(Vm.PublicHolidayId); if (publicHolidayGlobal != null) { if (string.IsNullOrEmpty(publicHolidayGlobal.CompanyUsed)) { publicHolidayGlobal.CompanyUsed = ""; } List <string> listCompanyUsed = publicHolidayGlobal.CompanyUsed.Split(';').ToList(); if (!listCompanyUsed.Contains(Vm.CompanyId.ToString())) { listCompanyUsed.Add(Vm.CompanyId.ToString()); } publicHolidayGlobal.CompanyUsed = string.Join(";", listCompanyUsed.ToArray()); _publicHolidayRepository.Update(publicHolidayGlobal); } SaveChanges(); return(entity); }
public void Update(PublicHolidayViewModel Vm) { var data = _mapper.Map <PublicHolidayViewModel, PublicHoliday>(Vm); _publicHolidayRepository.Update(data); SaveChanges(); }