public long Create(BusinessUnitKPIScorecard entity) { CommonHelper.ValidateArgumentNotNull(entity, nameof(entity)); Helper.ValidateTodayIsAllowedUpdateDate(entity.Year, entity.Month, InputAllowedInDays); int count = BusinessUnitKPIScorecardService.Search(new BusinessUnitKPIScorecardSearchCriteria { // use PageNumber=1 and PageSize=0 to get count only PageNumber = 1, BusinessUnitId = entity.BusinessUnit?.Id, YearId = entity.Year.Id, MonthId = entity.Month.Id }).TotalRecords; if (count > 0) { throw new BusinessProcessingException( "BusinessUnitKPIScorecard already exists for the given year and month."); } // populate audit fields PopulateAuditFields(entity, null, creating: true); return(BusinessUnitKPIScorecardService.Create(entity).Id); }
public BusinessUnitKPIScorecard Update(long id, BusinessUnitKPIScorecard entity) { CommonHelper.ValidateArgumentNotNull(entity, nameof(entity)); Helper.ValidateTodayIsAllowedUpdateDate(entity.Year, entity.Month, InputAllowedInDays); var existing = BusinessUnitKPIScorecardService.Get(id); if (!IsAdmin()) { Helper.ValidateStatusIsDraft(existing.Status); } // populate audit fields PopulateAuditFields(entity, existing); entity.Id = id; return(BusinessUnitKPIScorecardService.Update(entity)); }
public SearchResult <BusinessUnitKPIScorecard> Search([FromUri] BusinessUnitKPIScorecardSearchCriteria criteria) { criteria = criteria ?? new BusinessUnitKPIScorecardSearchCriteria(); return(BusinessUnitKPIScorecardService.Search(criteria)); }
public BusinessUnitKPIScorecard Get(long id) { return(BusinessUnitKPIScorecardService.Get(id)); }