public ActionResult Create(DepotVM v) { tblDepot a = new tblDepot(); if (ModelState.IsValid) { // a.CountryID = 1;// v.CountryID; //a.CityID = 19;// v.CityID; a.CountryName = v.CountryName; a.CityName = v.CityName; a.Depot = v.Depot; a.CompanyID = 1; a.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); a.IsOwn = v.IsOwn; if (v.IsOwn == false) { a.AgentID = v.AgentID; } db.tblDepots.Add(a); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully added Depot."; return(RedirectToAction("Index")); } return(View()); }
public JsonResult ChangeBranch(int id) { try { tblDepot depot = db.tblDepots.Find(id); //Year Setting //int? branchid = (from u2 in db.tblDepots where u2.ID == id select u2.BranchID).FirstOrDefault(); Session["CurrentBranchID"] = depot.BranchID; Session["CurrentDepotID"] = id; Session["CurrentDepot"] = depot.Depot; int startyearid = Convert.ToInt32(db.BranchMasters.Find(depot.BranchID).AcFinancialYearID); DateTime branchstartdate = Convert.ToDateTime(db.AcFinancialYears.Find(startyearid).AcFYearFrom); var allyear = (from c in db.AcFinancialYears where c.AcFYearFrom >= branchstartdate select c).OrderByDescending(cc => cc.AcFYearFrom).ToList(); Session["FYear"] = allyear; return(Json(new { status = "ok", depotname = depot.Depot, message = "Active Depot Selection changed to " + depot.Depot }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { status = "Failed", depotname = "", message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteConfirmed(int id) { tblDepot dep = db.tblDepots.Find(id); db.tblDepots.Remove(dep); db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully Deleted Depot."; return(RedirectToAction("Index")); }
// // GET: /Depot/Edit/5 public ActionResult Edit(int id = 0) { tblDepot tbldepot = db.tblDepots.Find(id); //ViewBag.Country = db.CountryMasters.ToList(); //ViewBag.Hubs = (from c in db.CityMasters where c.IsHub == true && c.CountryID==tbldepot.CountryID select c).ToList(); ViewBag.Agent = db.AgentMasters.ToList(); DepotVM v = new DepotVM(); if (tbldepot == null) { return(HttpNotFound()); } else { v.ID = tbldepot.ID; //v.CountryID = tbldepot.CountryID.Value; //v.CityID = tbldepot.CityID.Value; //a.CityID = 19;// v.CityID; v.CountryName = tbldepot.CountryName; v.CityName = tbldepot.CityName; v.CompanyID = tbldepot.CompanyID; v.Depot = tbldepot.Depot; v.IsOwn = tbldepot.IsOwn.Value; v.AgentID = tbldepot.AgentID; if (v.IsOwn == true) { v.Own = "True"; } else { v.Own = "False"; } } return(View(v)); }
public ActionResult Edit(DepotVM v) { tblDepot a = new tblDepot(); if (ModelState.IsValid) { a.ID = v.ID; a.CompanyID = v.CompanyID; a.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString()); a.CityID = 19;// v.CityID; a.CountryName = v.CountryName; a.CityName = v.CityName; a.IsOwn = v.IsOwn; a.AgentID = v.AgentID; a.Depot = v.Depot; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); TempData["SuccessMsg"] = "You have successfully Updated Depot."; return(RedirectToAction("Index")); } return(View()); }