private MasterEntity GetOutletVisitDayEntity(MasterBaseDTO masterBase) { OutletVisitDayDTO dto = masterBase as OutletVisitDayDTO; OutletVisitDay entity = new OutletVisitDay(masterBase.MasterId, masterBase.DateCreated, masterBase.DateLastUpdated, (EntityStatus)masterBase.StatusId); entity.Day = (DayOfWeek)dto.Day; entity.EffectiveDate = dto.EffectiveDate; entity.Outlet = new CostCentreRef{Id=dto.OutletMasterId}; return entity; }
protected Guid CreateOutletVistDay(Guid outletId, DayOfWeek day) { OutletVisitDay p = new OutletVisitDay(Guid.NewGuid()) { EffectiveDate = DateTime.Now.AddDays(-1), Outlet = new CostCentreRef { Id = outletId }, Day = day }; return _outletVisitDayRepository.Save(p); }
public OutletVisitDayDTO Map(OutletVisitDay priority) { if (priority == null) return null; return Mapper.Map<OutletVisitDay, OutletVisitDayDTO>(priority); }
public HttpResponseMessage OutletVisitDayAdd(List<OutletVisitDayItem> outletVisitDayItems) { var response = new ResponseBool {Success = false}; using (TransactionScope scope = TransactionUtils.CreateTransactionScope()) { try { foreach (OutletVisitDayItem outletVisitDayItem in outletVisitDayItems) { var item = new OutletVisitDay(outletVisitDayItem.MasterId) { Outlet = new CostCentreRef() {Id = outletVisitDayItem.OutletId}, EffectiveDate = outletVisitDayItem.EffectiveDate, _DateLastUpdated = outletVisitDayItem.DateLastUpdated, _Status = (EntityStatus) outletVisitDayItem.StatusId, _DateCreated = outletVisitDayItem.DateCreated, Day = outletVisitDayItem.Day }; _outletVisitDayRepository.Save(item); } response.Success = true; response.ErrorInfo = "Successfully saved outlet visit days"; scope.Complete(); } catch (DomainValidationException dve) { string errorMsg = dve.ValidationResults.Results.Aggregate("Error: Invalid outlet visit day fields.\n", (current, msg) => current + ("\t- " + msg.ErrorMessage + ".\n")); response.ErrorInfo = errorMsg; _log.Error(errorMsg, dve); //return errorMsg; } catch (Exception ex) //any other { response.ErrorInfo = "Error: An error occurred when saving the outlet visit day."; _log.Error("Error: An error occurred when saving the outlet visit day.", ex); } } return Request.CreateResponse(HttpStatusCode.OK, response); }