public ActionResult CreateSave(TifinMaster ObjTifin) { if (ObjTifin.NumberOfTifin <= 0) { return(Json(new { msg = "Number Of Tifin Must Be more than zero" })); } else if (ObjTifin.NumberOfTifin > 20) { return(Json(new { msg = "Number Of Tifin Not Be more than 20" })); } if (ObjTifin.TifinID == 0) { for (int i = 0; i < ObjTifin.NumberOfTifin; i++) { TifinMaster TifinObj = new TifinMaster(); TifinObj.NumberOfTifin = ObjTifin.NumberOfTifin; TifinObj.TifinColor = ObjTifin.TifinColor; TifinObj.TifinStatus = "UnUsed"; TifinObj.TifinAtLocation = "CENTER"; TifinObj.TifinTakenBy = Session["UID"].ToString(); TifinObj.TifinID = 0; if (TifinObj.Save() > 0) { for (int ii = 0; ii < ObjTifin.TifinType; ii++) { TifinRackMaster ObjRackMaster = new TifinRackMaster(); ObjRackMaster.TifinId = TifinObj.TifinID; ObjRackMaster.TifinRackStatus = "UnUsed"; ObjRackMaster.Save(); } } } } return(RedirectToAction("index")); }
public ActionResult AlloteTifinToMess() { string TifinCode = Request.QueryString["TifinCode"]; string MessId = Request.QueryString["MID"]; Mess ObjMess = Mess.List.Find(x => x.MID == int.Parse(MessId)); if (ObjMess == null) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Please Select Mess " }, JsonRequestBehavior.AllowGet)); } TifinMaster ObjTifin = TifinMaster.List.Values.ToList().Find(x => x.TifinID == int.Parse(TifinCode)); if (ObjTifin == null) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Invalid Tifin Code " }, JsonRequestBehavior.AllowGet)); } // MAX TIFIN CONDITION TO MESS int TotolTifinAtMess = TifinMaster.List.Values.ToList().FindAll(x => x.TifinTakenBy == MessId).Count; if (TotolTifinAtMess >= ObjMess.NumberOfTifin) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Total Tifin Limit Reached For Mess. Limit Is " + ObjMess.NumberOfTifin }, JsonRequestBehavior.AllowGet)); } if (ObjTifin.TifinAtLocation != "CENTER") { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "This Tifin Already Used By " + ObjTifin.TifinAtLocation }, JsonRequestBehavior.AllowGet)); } //change tifin status ObjTifin.TifinAtLocation = "MESS"; ObjTifin.TifinTakenBy = ObjMess.MID.ToString(); if (ObjTifin.Save() == 0) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Unable To Allote Tifin" }, JsonRequestBehavior.AllowGet)); } return(Content("Alloted")); }
public ActionResult PostDataAssemble() { int OrderId = int.Parse(Request.QueryString["OrderId"].ToString()); int TifinCode = int.Parse(Request.QueryString["TifinCode"].ToString()); int OrderItemId = int.Parse(Request.QueryString["OrderItemId"]); List <Orders> ListOfOrder = Orders.List; List <TifinMaster> ListOfTifin = TifinMaster.List.Values.ToList(); OrderItem OrderItemObj = OrderItem.List.Find(x => x.OIID == OrderItemId); TifinMaster ObjTifin = ListOfTifin.Find(x => x.TifinID == TifinCode); Orders order = ListOfOrder.Find(x => x.OID == OrderId); Orders AlreadyTifinUsedInOtherOrder = ListOfOrder.Find(x => x.TifinIds.Contains(TifinCode.ToString()) && x.OID != order.OID && (x.Status != "Order-Completed")); if (ObjTifin != null && order != null) { if (AlreadyTifinUsedInOtherOrder != null) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Tifin Number Already Used In Order No" + AlreadyTifinUsedInOtherOrder.OID.ToString() }, JsonRequestBehavior.AllowGet)); } if (OrderItemObj != null) { OrderItemObj.TifinID = TifinCode; OrderItemObj.ItemAssembleBy = int.Parse(Session["UID"].ToString()); if (OrderItemObj.Save() <= 0) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Unable To Save Order " }, JsonRequestBehavior.AllowGet)); } } if (ObjTifin.TifinStatus.Contains("UnUsed") || !order.TifinIds.Contains(TifinCode.ToString())) { if (order.TifinIds != null && order.TifinIds != "") { order.TifinIds = TifinCode.ToString() + ","; } else { order.TifinIds = order.TifinIds + TifinCode.ToString() + ","; } if (order.Save() > 0) { List <OrderItem> TotalOrderItemList = OrderItem.List.FindAll(x => x.OID == OrderItemObj.OID); List <OrderItem> TotalOrderCompleted = TotalOrderItemList.FindAll(x => x.Status == 2 && x.TifinID > 0);// order collected and tifins alloted in all OIID RackElements if (TotalOrderCompleted.Count == TotalOrderItemList.Count) { Orders ObjOrder = Orders.List.Find(x => x.OID == OrderItemObj.OID); if (ObjOrder != null) { ObjOrder.Status = "Order-Assemble"; if (ObjOrder.Save() <= 0) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Server Busy For Set Status As Assemble" }, JsonRequestBehavior.AllowGet)); } } } if (ObjTifin.TifinStatus.Contains("UnUsed") || ObjTifin.TifinAtLocation != "CENTER") { ObjTifin.TifinStatus = "Used"; ObjTifin.TifinAtLocation = "CENTER"; ObjTifin.TifinTakenBy = Session["UID"].ToString(); ObjTifin.Save(); } } } } else { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(new { msg = "Tifin Number or Order number is invalid please scan valid tifin code" }, JsonRequestBehavior.AllowGet)); } return(Content("")); }