public async Task <ServiceResult> Add([FromBody] DeliveryAddModel apiEntity) { var entity = DeliveryAddModel.Map(apiEntity); var result = await _contentGroupService.AddAsync(entity); if (result.TryCastModel(out ContentGroup contentGroup)) { result.ViewModel = DeliveryViewModel.Map(contentGroup); } return(result); }
public async Task <ServiceResult> Edit(Guid id, [FromBody] DeliveryEditModel apiEntity) { var entity = DeliveryEditModel.Map(apiEntity, id); var result = await _contentGroupService.UpdateAsync(entity); if (result.TryCastModel(out ContentGroup contentGroup)) { result.ViewModel = DeliveryViewModel.Map(contentGroup); } return(result); }
public async Task <DeliveryViewModel> GetOne(Guid id) { var entity = await _contentGroupService.FindByAsync(ContentGroupName.Delivery, x => x.Id == id); return(DeliveryViewModel.Map(entity)); }