コード例 #1
0
 public ActionResult Edit(SalesOrder salesOrder)
 {
     if (ModelState.IsValid)
     {
         if (salesOrder.SalesOrderId == 0)
         {
             salesOrder.CreatedTime = System.DateTime.Now;
             salesOrder.CreatedById = DataConvert.GetInt32(Session["AdminId"]);
             salesOrder.CreatedByName = DataConvert.GetString(Session["AdminName"]);
         }
         salesOrder.UpdatedTime = System.DateTime.Now;
         salesOrder.UpdatedById = DataConvert.GetInt32(Session["AdminId"]);
         salesOrder.UpdatedByName = DataConvert.GetString(Session["AdminName"]);
         shoeStoreRepository.SaveSalesOrder(salesOrder);
         TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Success, string.Format("{0} has been created!", salesOrder.SalesOrderId));
         return RedirectToAction("List");
     }
     else
     {
         //There is something wrong with the data values
         TempData["message"] = MessageHelper.BuildMessage(EnumSevereLevel.Error, "There is something wrong with the data values, please check!");
         ViewBag.SalesOrderStatuss = shoeStoreRepository.SalesOrderStatuss;
         ViewBag.Customers = GetAppUsersInRole(AdminConstants.ROLE_CUSTOMER);
         return View(salesOrder);
     }
 }
コード例 #2
0
 public void SaveSalesOrder(SalesOrder salesOrder)
 {
     if (salesOrder.SalesOrderId == 0)
     {
         context.SalesOrders.Add(salesOrder);
     }
     else
     {
         SalesOrder dbEntry = context.SalesOrders.Find(salesOrder.SalesOrderId);
         if (dbEntry != null)
         {
             dbEntry.SalesOrderStatusId = salesOrder.SalesOrderStatusId;
             dbEntry.UpdatedTime = salesOrder.UpdatedTime;
             dbEntry.UpdatedById = salesOrder.UpdatedById;
             dbEntry.UpdatedByName = salesOrder.UpdatedByName;
         }
     }
     context.SaveChanges();
 }