예제 #1
0
 private PlaceGroupModel ViewToModel(PlaceGroupViewModel model)
 {
     return(new PlaceGroupModel
     {
         Id = model.Id,
         Code = model.Code,
         Name = model.Name,
         Building = model.Building,
         Enabled = model.Enabled,
         SubscriberId = model.SubscriberId
     });
 }
예제 #2
0
        public async Task <IActionResult> Update([FromBody] PlaceGroupViewModel record)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var updatedRecord = ModelToView((await _AppService.Update(ViewToModel(record))).First());

                return(Accepted($"api/[controller]/{ updatedRecord.Id }", updatedRecord));
            }
            catch (ApplicationException ex)
            {
                return(new BadRequestObjectResult(ex));
            }
            catch (Exception ex)
            {
                return(new BadRequestObjectResult(ex));
            }
        }