/// <summary> /// Delete fiscalSchedule /// </summary> /// <param name="fiscalSchedule">FiscalSchedule</param> public virtual void DeleteFiscalSchedule(FiscalSchedule fiscalSchedule) { if (fiscalSchedule == null) { throw new ArgumentNullException(nameof(fiscalSchedule)); } _fiscalScheduleRepository.Delete(fiscalSchedule); //event notification _eventPublisher.EntityDeleted(fiscalSchedule); }
/// <summary> /// Inserts fiscalSchedule /// </summary> /// <param name="fiscalSchedule">FiscalSchedule</param> public virtual void InsertFiscalSchedule(FiscalSchedule fiscalSchedule) { if (fiscalSchedule == null) { throw new ArgumentNullException(nameof(fiscalSchedule)); } if (fiscalSchedule is IEntityForCaching) { throw new ArgumentException("Cacheable entities are not supported by Entity Framework"); } _fiscalScheduleRepository.Insert(fiscalSchedule); //cache _cacheManager.RemoveByPattern(ResearchFiscalScheduleDefaults.FiscalSchedulesPatternCacheKey); //_staticCacheManager.RemoveByPattern(ResearchFiscalScheduleDefaults.FiscalSchedulesPatternCacheKey); //event notification _eventPublisher.EntityInserted(fiscalSchedule); }
/// <summary> /// Prepare fiscalSchedule model /// </summary> /// <param name="model">FiscalSchedule model</param> /// <param name="fiscalSchedule">FiscalSchedule</param> /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param> /// <returns>FiscalSchedule model</returns> public virtual FiscalScheduleModel PrepareFiscalScheduleModel(FiscalScheduleModel model, FiscalSchedule fiscalSchedule, bool excludeProperties = false) { if (fiscalSchedule != null) { //fill in model values from the entity model = model ?? fiscalSchedule.ToModel <FiscalScheduleModel>(); model.Id = fiscalSchedule.Id; model.FiscalYear = fiscalSchedule.FiscalYear; model.ClosingDate = fiscalSchedule.ClosingDate.AddYears(543); model.FiscalCode = fiscalSchedule.FiscalCode; model.FiscalTimes = fiscalSchedule.FiscalTimes; model.OpeningDate = fiscalSchedule.OpeningDate.AddYears(543); } else { model.FiscalCode = _fiscalScheduleService.GetNextNumber(); model.FiscalYear = DateTime.Today.Year + 543; model.OpeningDate = DateTime.Today.AddYears(543); model.ClosingDate = DateTime.Today.AddYears(544); model.FiscalTimes = 1; } _baseAdminModelFactory.PrepareFiscalYears(model.AvailableFiscalYears, true, "--ระบุปี--"); return(model); }