public IHttpActionResult Post([FromBody] CreateSalesAreaModel command) { if (command == null || !ModelState.IsValid) { return(this.Error().InvalidParameters()); } Validate(command.BaseDemographic1, command.BaseDemographic2); //Input values are validated by calling Validate method as part of MapFrom var salesArea = SalesArea.MapFrom(Guid.NewGuid(), command.Name, command.ShortName, command.CurrencyCode, command.BaseDemographic1, command.BaseDemographic2, command.ChannelGroup, command.StartOffset, command.DayDuration); _salesAreaRepository.Add(salesArea); _salesAreaRepository.SaveChanges(); return(Ok(_mapper.Map <SalesAreaModel>(salesArea))); }
public SalesArea Add(SalesArea model) { _salesAreaRepository.Add(model); return(model); }