public IHttpActionResult PutProducto(int id, Producto producto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != producto.idProducto) { return(BadRequest()); } try { ProductoBLL.Update(producto); return(Content(HttpStatusCode.OK, "Producto actualizado correctamente")); } catch (Exception ex) { Producto pro = ProductoBLL.Get(id); if (pro == null) { return(NotFound()); } else { return(StatusCode(HttpStatusCode.NoContent)); } } }
public ActionResult Edit([Bind(Include = "idProducto,nombre,precio,comentario,estado")] Producto producto) { if (ModelState.IsValid) { ProductoBLL.Update(producto); return(RedirectToAction("Index")); } return(View(producto)); }
public static Producto ActualizarProducto(string descripcion, string nombre, string precio, string medida, string idcategoria, string id, string costo, string stock) { ProductoBLL.Update(descripcion, nombre, precio, medida, idcategoria, id, costo, stock); Producto objProducto = ProductoBLL.SelectById(Convert.ToInt32(id)); return(objProducto); }
public IHttpActionResult Put(Producto p) { try { ProductoBLL.Update(p); return(Content(HttpStatusCode.OK, "Producto actualizado correctamente")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Edit([Bind(Include = "prd_id,cat_id,prm_id,prd_nom,prd_img,prd_tal,prd_crt,prd_cnt,prd_prc,prd_dateOfCreated")] Producto producto) { if (Request.Files[0] != null && Request.Files[0].ContentLength > 0) { EliminarArchivo(producto.prd_img); producto.prd_img = SubirImagen(Request.Files[0]); } else { Producto prd = ProductoBLL.Get(producto.prd_id); producto.prd_img = prd.prd_img; } if (ModelState.IsValid) { ProductoBLL.Update(producto); return(RedirectToAction("Index")); } ViewBag.cat_id = new SelectList(CategoriaBLL.List(), "cat_id", "cat_nom", producto.cat_id); ViewBag.prm_id = new SelectList(PromocionBLL.List(), "prm_id", "prm_nom", producto.prm_id); return(View(producto)); }
private void BtnGuardar_Click(object sender, EventArgs e) { if (id == null) { entity = new Entities.Producto(); } CargarEntity(entity); var validation = new Helps.DataValidations(entity).Validate(); bool valid = validation.Item1; if (valid == true) { if (id == null) { try { entity = bll.Insert(entity); InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Producto: " + entity.codigo, "", "")); Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("guardadoOK")); this.Close(); } catch (Exception ex) { if (ex.Message == EValidaciones.existe) { Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorExiste")); } else { InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Producto: " + entity.codigo, ex.StackTrace, ex.Message)); Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("guardadoError") + "\n" + ex.Message); } } } else { try { bll.Update(entity); InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Producto: " + entity.codigo, "", "")); Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("editadoOK")); this.Close(); } catch (Exception ex) { if (ex.Message == EValidaciones.existe) { Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("errorExiste")); } else { InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Producto: " + entity.codigo, ex.StackTrace, ex.Message)); Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("editadoError") + "\n" + ex.Message); } } } } else { string messageValid = validation.Item2; Notifications.FrmInformation.InformationForm(messageValid); } }