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 PublicHolidayViewModel GetById(int id) { var model = _publicHolidayRepository.Get(id); return(_mapper.Map <PublicHoliday, PublicHolidayViewModel>(model)); }