public async Task <IActionResult> Insert(PresupuestoModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var presupuesto = _mapper.Map <PresupuestoDto>(model);
            await _presupuestoRepositorio.Insertar(presupuesto);

            return(Ok(model));
        }
Пример #2
0
 public string Put(Guid id, [FromBody] PresupuestoModel model)
 {
     try
     {
         BO.Presupuesto modelUpdated = PresupuestosHandler.Update(id, model.GetBusinessObject());
         return(string.Format("La cotización se modificó exitosamente."));
     }
     catch (Exception ex)
     {
         Log.Error(null, ex);
         throw ex;
     }
 }
        public async Task <IActionResult> Edit(long id, PresupuestoModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var presupuesto = _mapper.Map <PresupuestoDto>(model);

            presupuesto.Id = id;
            await _presupuestoRepositorio.Modificar(presupuesto);

            return(Ok(model));
        }
Пример #4
0
 public IActionResult Post([FromBody] PresupuestoModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var presupuestoBo = model.GetBusinessObject();
             PresupuestosHandler.SaveChildren(presupuestoBo.Items);
             Guid savedId = PresupuestosHandler.Save(presupuestoBo);
             return(new ObjectResult(savedId));
         }
         return(new ObjectResult(model));
     }
     catch (Exception ex)
     {
         Log.Error(null, ex);
         throw ex;
     }
 }