public ActionResult Create(Orders_Items orders_items)
        {
            if (ModelState.IsValid)
            {
                db.Orders_Items.AddObject(orders_items);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", orders_items.SupplierId);
            return View(orders_items);
        }
        public JsonResult AjaxCreate(Orders_Items orderItem)
        {
            if (Authorized(RoleType.OrdersWriter))
            {
                bool wasCreated;
                using (OrderItemsRepository itemRep = new OrderItemsRepository(CurrentUser.CompanyId, orderItem.SupplierId))
                {
                    wasCreated = itemRep.Create(orderItem);
                }

                if (wasCreated)
                    return Json(new { success = true, message = String.Empty, newItemId = orderItem.Id }, JsonRequestBehavior.AllowGet);
                else
                    return Json(new { success = false, message = Loc.Dic.error_supplier_item_create_error }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { success = false, message = Loc.Dic.error_no_permission }, JsonRequestBehavior.AllowGet);
            }
        }
Exemple #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Orders_Items EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrders_Items(Orders_Items orders_Items)
 {
     base.AddObject("Orders_Items", orders_Items);
 }
Exemple #4
0
 /// <summary>
 /// Create a new Orders_Items object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 /// <param name="isCanceled">Initial value of the IsCanceled property.</param>
 /// <param name="companyId">Initial value of the CompanyId property.</param>
 public static Orders_Items CreateOrders_Items(global::System.Int32 id, global::System.String title, global::System.DateTime creationDate, global::System.Boolean isCanceled, global::System.Int32 companyId)
 {
     Orders_Items orders_Items = new Orders_Items();
     orders_Items.Id = id;
     orders_Items.Title = title;
     orders_Items.CreationDate = creationDate;
     orders_Items.IsCanceled = isCanceled;
     orders_Items.CompanyId = companyId;
     return orders_Items;
 }
 public ActionResult Edit(Orders_Items orders_items)
 {
     if (ModelState.IsValid)
     {
         db.Orders_Items.Attach(orders_items);
         db.ObjectStateManager.ChangeObjectState(orders_items, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.SupplierId = new SelectList(db.Suppliers, "Id", "Name", orders_items.SupplierId);
     return View(orders_items);
 }