/// <summary> /// Update negocioe Information /// </summary> /// <param name="Emp"></param> /// <returns></returns> public string UpdateNegocio(negocios Neg) { var file = Request.Files[0]; string fileName; if (Neg != null) { fileName = Guid.NewGuid() + Path.GetExtension(file.FileName); file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName)); using (appUEntities1 Obj = new appUEntities1()) { var Neg_ = Obj.Entry(Neg); negocios negObj = Obj.negocios.Where(x => x.idNegocio == Neg.idNegocio).FirstOrDefault(); negObj.nombre = Neg.nombre; negObj.calle = Neg.calle; negObj.numero = Neg.numero; negObj.colonia = Neg.colonia; negObj.ciudad = Neg.ciudad; negObj.imgNegocio = fileName; negObj.permitePagosTarjeta = Neg.permitePagosTarjeta; negObj.precioEnvio = Neg.precioEnvio; negObj.descripcion = Neg.descripcion; negObj.correo = Neg.correo; negObj.codigoPostal = Neg.codigoPostal; Obj.SaveChanges(); return("negocio Updated Successfully"); } } else { return("negocio Not Updated! Try Again"); } }
/// <summary> /// Update negocioe Information /// </summary> /// <param name="Pro"></param> /// <returns></returns> public string Update_producto(productos pro) { var file = Request.Files[0]; string fileName; if (pro != null) { fileName = Guid.NewGuid() + Path.GetExtension(file.FileName); file.SaveAs(Path.Combine(Server.MapPath("~/imagenesProductos"), fileName)); using (appUEntities1 Obj = new appUEntities1()) { var Neg_ = Obj.Entry(pro); productos proObj = Obj.productos.Where(x => x.idProducto == pro.idProducto).FirstOrDefault(); proObj.imgProducto = fileName; proObj.producto = pro.producto; proObj.descripcion = pro.descripcion; proObj.precio = pro.precio; Obj.SaveChanges(); return("producto Updated Successfully"); } } else { return("producto Not Updated! Try Again"); } }
/// <summary> /// Delete negocioe Information /// </summary> /// <param name="Neg"></param> /// <returns></returns> public string Delete_negocio(negocios Neg) { if (Neg != null) { var Neg_ = db.Entry(Neg); if (Neg_.State == System.Data.Entity.EntityState.Detached) { db.negocios.Attach(Neg); db.negocios.Remove(Neg); } db.SaveChanges(); return("negocioe Deleted Successfully"); } else { return("negocioe Not Deleted! Try Again"); } }
private void eliminarProductoCarrito(detalleVenta dv) { List <detalleVenta> detalle = Obj.detalleVenta.Where(x => x.fkVenta == dv.fkVenta).ToList(); ventas ventaEliminar = Obj.ventas.Find(dv.fkVenta); if (detalle.Count == 1) { Obj.Entry(dv).State = EntityState.Deleted; Obj.Entry(ventaEliminar).State = EntityState.Deleted; Request.Cookies["IdVenta"].Value = ""; Request.Cookies["IdVenta"].Expires = DateTime.Now.AddDays(-1D); Response.Cookies.Add(Request.Cookies["IdVenta"]); } else { updateVenta(dv.fkVenta, -1 * dv.precio, ventaEliminar.fkNegocio); Obj.Entry(dv).State = EntityState.Deleted; Obj.SaveChanges(); } }
/// <summary> /// Update negocioe Information /// </summary> /// <param name="Pro"></param> /// <returns></returns> public string cambiarEstatusProducto(productos pro) { if (pro != null) { using (appUEntities1 Obj = new appUEntities1()) { var Neg_ = Obj.Entry(pro); productos proObj = Obj.productos.Where(x => x.idProducto == pro.idProducto).FirstOrDefault(); proObj.activo = pro.activo; Obj.SaveChanges(); return("negocioe Updated Successfully"); } } else { return("negocioe Not Updated! Try Again"); } }
/// <summary> /// Delete negocioe Information /// </summary> /// <param name="Neg"></param> /// <returns></returns> public string Delete_negocio(negocios Neg) { if (Neg != null) { using (appUEntities1 Obj = new appUEntities1()) { var Neg_ = Obj.Entry(Neg); if (Neg_.State == System.Data.Entity.EntityState.Detached) { Obj.negocios.Attach(Neg); Obj.negocios.Remove(Neg); } Obj.SaveChanges(); return("negocioe Deleted Successfully"); } } else { return("negocioe Not Deleted! Try Again"); } }