Beispiel #1
0
 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 PostCollectionItem()
        {
            int             NumberOfRackInOrderItem    = 0;
            string          ReturnNumberOfElementInOID = "Server Busy,";// defaul one item count;for returning result to ajax
            int             OrderItemID    = int.Parse(Request.QueryString["OrderItemId"]);
            int             ElementRackID  = int.Parse(Request.QueryString["ElementCode"]);
            TifinRackMaster ObjElementRack = TifinRackMaster.List.Values.ToList().Find(x => x.TifinRackId == ElementRackID);
            OrderItem       ObjOrderItem   = OrderItem.List.Find(x => x.OIID == OrderItemID);

            if (ObjOrderItem != null)
            {
                if (ObjElementRack != null && ObjElementRack.TifinRackStatus != ("Used"))
                {
                    int TotalItems = ObjOrderItem.Count;

                    if (ObjOrderItem.TifinRackIds.Contains(","))
                    {
                        string[] TifinRackIds = ObjOrderItem.TifinRackIds.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        NumberOfRackInOrderItem = TifinRackIds.Length;
                    }
                    if (NumberOfRackInOrderItem > TotalItems)
                    {
                        Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                        return(Json(new { msg = "Element Racks Cannot More Than Total Item in Order Item. Total Rack Element in Item is going to" + NumberOfRackInOrderItem }, JsonRequestBehavior.AllowGet));
                    }
                    ObjOrderItem.Status = 2;    // 2 for approved by foodoo admin
                    if (ObjOrderItem.TifinRackIds != null && ObjOrderItem.TifinRackIds != "")
                    {
                        ObjOrderItem.TifinRackIds = ObjOrderItem.TifinRackIds + ElementRackID.ToString() + ",";
                    }
                    else
                    {
                        ObjOrderItem.TifinRackIds = ElementRackID.ToString() + ",";
                    }
                    if (Session["UID"] == null)
                    {
                        ObjOrderItem.UpdatedBy = 0;
                    }
                    else
                    {
                        ObjOrderItem.UpdatedBy     = int.Parse(Session["UID"].ToString());
                        ObjOrderItem.ItemCollectBy = int.Parse(Session["UID"].ToString());
                    }
                    ObjOrderItem.UpdationDate = System.DateTime.Now;
                    if (ObjOrderItem.Save() > 0)
                    {
                        ReturnNumberOfElementInOID     = ObjOrderItem.TifinRackIds;
                        NumberOfRackInOrderItem       += 1;// increament number of rack in as per OID count
                        ObjElementRack.TifinRackStatus = "Used";
                        ObjElementRack.Save();
                        List <OrderItem> TotalOrderItemList  = OrderItem.List.FindAll(x => x.OID == ObjOrderItem.OID);
                        List <OrderItem> TotalOrderCompleted = TotalOrderItemList.FindAll(x => x.Status == 2);
                        if (TotalOrderCompleted.Count == TotalOrderItemList.Count)
                        {
                            Orders ObjOrder = Orders.List.Find(x => x.OID == ObjOrderItem.OID);
                            if (ObjOrder != null)
                            {
                                ObjOrder.Status = "Order-Collected";
                                if (ObjOrder.Save() <= 0)
                                {
                                }
                            }
                        }
                    }
                    else
                    {
                        Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                        return(Json(new { msg = "Can't collect Item Server is Too Busy" }, JsonRequestBehavior.AllowGet));
                    }
                }
                else if (ObjElementRack != null)
                {
                    Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                    return(Json(new { msg = "This Element Is Aready Used" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                    return(Json(new{ msg = "Element Not Found Plese Check Element Code" }, JsonRequestBehavior.AllowGet));
                }
            }


            return(Content(ReturnNumberOfElementInOID));
        }