Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(WellView model)
        {
            try
            {
                var editedItem = (await _wellRepository.GetSingleAsync(model.Id));
                if (editedItem == null)
                {
                    return(NotFound());
                }
                editedItem.Name       = model.Name;
                editedItem.CompanyId  = model.CompanyId;
                editedItem.ShopId     = model.ShopId;
                editedItem.FieldId    = model.FieldId;
                editedItem.WellTypeId = model.WellTypeId;
                editedItem.Altitude   = model.Altitude;
                editedItem.ZabI       = model.ZabI;
                editedItem.ZabF       = model.ZabF;
                await _wellRepository.AddOrUpdateAsync(editedItem, true);

                return(Ok());
            }
            catch (Exception e)
            {
                Log.Error(e, "WellController.Edit");
                return(BadRequest(_messageModelBuilder.CreateModel("500", e.Message)));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(WellView model)
        {
            try
            {
                await _wellRepository.AddOrUpdateAsync(_mapper.Map <WellView, Well>(model), true);

                return(Ok());
            }
            catch (Exception e)
            {
                Log.Error(e, "WellController.Create");
                return(BadRequest(_messageModelBuilder.CreateModel("500", e.Message)));
            }
        }