public ActionResult Create(InboundMaster InventoryMaster)
        {
            if (ModelState.IsValid)
            {
                InventoryMaster.CreatedDate = DateTime.Now;
                InventoryMaster.ModifiedDate = DateTime.Now;
                InventoryMaster.UserID = User.Identity.Name;
                //InventoryMaster.Date = DateTime.Now;
                //InventoryMaster.Type= InventoryMaster.Type;
                InventoryMaster.TempleID = Convert.ToInt32(Request.Cookies["dcsankirtan"].Values["TempleID"]);
                db.InboundMasters.Add(InventoryMaster);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(InventoryMaster);
        }
 public ActionResult Edit(InboundMaster inboundMaster)
 {
     if (ModelState.IsValid)
     {
         var TempleID = Convert.ToInt32(Request.Cookies["dcsankirtan"].Values["TempleID"]);
         if (inboundMaster.TempleID == TempleID)
         {
             db.Entry(inboundMaster).State = EntityState.Modified;
             inboundMaster.ModifiedDate = DateTime.Now;
             //    inboundMaster.CreatedDate = DateTime.Now;
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(inboundMaster);
 }
        //
        // GET: /Inventory/
        public ActionResult Index(int? currentMonth, int? year)
        {
            int filteredMonth = DateTime.Now.Month;
            int filteredYear = DateTime.Now.Year;
            if (currentMonth != null)
            {
                filteredMonth = currentMonth.Value;
            }
            if (year != null)
            {
                filteredYear = year.Value;
            }
            ReportDataAccess summaryInfo = new ReportDataAccess();
            var TempleID = Convert.ToInt32(Request.Cookies["dcsankirtan"].Values["TempleID"]);
            var inboundList = db.InboundMasters.Where(o => o.Date.Value.Month == filteredMonth && o.Date.Value.Year == filteredYear && o.TempleID == TempleID)
                 .OrderByDescending(o => o.ModifiedDate).ToList();
            if (inboundList.Count == 0)
            {
                var lastestEvent = db.InboundMasters.OrderByDescending(o => o.CreatedDate).FirstOrDefault();
                if (lastestEvent == null)
                {
                    lastestEvent = new InboundMaster { Date = DateTime.Now, Description = "DummyForNewTemple" };
                }
                filteredMonth = lastestEvent.Date.Value.Month;
                filteredYear = lastestEvent.Date.Value.Year;
                inboundList = db.InboundMasters.Where(o => o.Date.Value.Month == filteredMonth && o.Date.Value.Year == filteredYear && o.TempleID == TempleID)
                   .OrderByDescending(o => o.ModifiedDate).ToList();
            }

            var orderedlist = inboundList.OrderByDescending(o => o.ModifiedDate);
            if (orderedlist.Count() == 0)
            {
                return View("InventoryDetails", new List<InboundMaster> { new InboundMaster { Date = DateTime.Now, Description = "DummyForNewTemple" } });

            }
            else
            {
                return View("InventoryDetails",orderedlist);

            }
        }