public ActionResult AddOperation(Operation newOperation, int idValue) { //Setting cur date and good for operation. newOperation.OperationTime = DateTime.Now; newOperation.GoodId = idValue; //Check for enough good at warehouse. if (newOperation.OperType == OperationType.Outcome && !GoodEnought(newOperation.GoodId, newOperation.Quantity)) { TempData["opMessage"] = "You haven't got enough good"; } else { using (_context = new WarehouseContext()) { //Setting user for operation. var uId = Convert.ToInt32(Session["UserId"]); var us = _context.UserProfiles.FirstOrDefault(x => x.UserId == uId); newOperation.User = us; //Save operation. _context.Operations.Add(newOperation); _context.SaveChanges(); TempData["opMessage"] = "Operation successfully saved"; } } //Refreshing detailinfo partial view. var gStat = new GoodStatisticViewModel(newOperation.GoodId); return(PartialView("~/Views/Goods/DetailInfo.cshtml", gStat)); }
/// <summary> /// Return view with detail info of new good. /// </summary> /// <param name="id">Good's id</param> /// <returns>partial view with good's detailed info</returns> public PartialViewResult DetailInfo(int id = -1) { _goodStatisticVM = new GoodStatisticViewModel(id); return(PartialView(_goodStatisticVM)); }