public virtual JsonResult AddShipping(ShippingPaymentCreateModel model) { var shipping = new ShippingType { Active = false, ShippingDescription = model.Description, ShippingName = model.Name, ShippingPrice = Convert.ToDecimal(model.Price.Replace(".", ",")), MaxWeight = Convert.ToDecimal(model.MaxWeight.Replace(".", ",")) }; try { _dbContext.ShippingTypes.Add(shipping); _dbContext.SaveChanges(); var ship = _dbContext.ShippingTypes.OrderByDescending(x => x.ShippingId).First(); return(Json(new { ship.ShippingId, ship.ShippingDescription, ship.ShippingName, ship.ShippingPrice, canDelete = ship.Orders.Count == 0, editActive = false, ship.MaxWeight, editWeight = false }, JsonRequestBehavior.AllowGet)); } catch { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public virtual JsonResult AddPayment(ShippingPaymentCreateModel model) { var payment = new PaymentType { Active = false, PaymentDescription = model.Description, PaymentName = model.Name, PaymentPrice = Convert.ToDecimal(model.Price.Replace(".", ",")) }; try { _dbContext.PaymentTypes.Add(payment); _dbContext.SaveChanges(); var pay = _dbContext.PaymentTypes.OrderByDescending(x => x.PaymentId).First(); return(Json(new { pay.PaymentId, pay.PaymentDescription, pay.PaymentName, pay.PaymentPrice, canDelete = pay.Orders.Count == 0, editActive = false }, JsonRequestBehavior.AllowGet)); } catch { return(Json(false, JsonRequestBehavior.AllowGet)); } }