public ActionResult AccountCreate(MSTR_Account Account) { if (!exLogic.User.hasAccess("ACCOUNT.CREATE")) return RedirectToAction("NoAccess", "Home"); if (ModelState.IsValid) { if (Session["UserId"] == null) { Session["UserId"] = -1; } Account.CreatedBy = Util.toInt(Session["UserID"].ToString()); Account.CreatedOn = DateTime.Now; db.MSTR_Account.Add(Account); db.SaveChanges(); //setting up binary code after the account id creation and saving String CodeBinary = Util.DecToBin(Account.AccountId); String SQL = "Update Mstr_Account set BinaryCode='" + CodeBinary + "' where AccountId=" + Account.AccountId; Util.doSQL(SQL); return RedirectToAction("AccountDetail", new { id = Account.AccountId }); } var viewModel = new ViewModel.AccountViewModel { Account = new MSTR_Account(), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), }; return View(viewModel); }
}//Account() public ActionResult AccountCreate() { if (!exLogic.User.hasAccess("ACCOUNT.CREATE")) return RedirectToAction("NoAccess", "Home"); ViewBag.Title = "Create Account"; var AccountModel = new ViewModel.AccountViewModel { Account = new MSTR_Account(), CountryList = Util.GetCountryLists("Country", "DroneName", "Code", "usp_Portal_DroneServiceType"), }; return View(AccountModel); }
public ActionResult AccountEdit(int id) { ViewBag.Title = "Edit Account"; if (!exLogic.User.hasAccess("ACCOUNT.EDIT")) return RedirectToAction("NoAccess", "Home"); var viewModel = new ViewModel.AccountViewModel { Account = db.MSTR_Account.Find(id), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), }; return View(viewModel); }
public ActionResult AccountEdit(Models.MSTR_Account Account) { ViewBag.Title = "Edit Account"; if (!exLogic.User.hasAccess("ACCOUNT.EDIT")) return RedirectToAction("NoAccess", "Home"); try { if (ModelState.IsValid) { if (Session["UserId"] == null) { Session["UserId"] = -1; } Account.ModifiedBy = Util.toInt(Session["UserID"].ToString()); Account.ModifiedOn = DateTime.Now; string SQL = "Update Mstr_Account set Name='" + Account.Name + "',Code='" + Account.Code + "',EmailId='" + Account.EmailId + "',MobileNo='" + Account.MobileNo + "',OfficeNo='" + Account.OfficeNo + "',IsActive='" + Account.IsActive + "',ModifiedBy=" + Session["UserId"] + ",ModifiedOn='" + DateTime.Now.ToString("yyyy - MM - dd") + "', AccountDescription='" + Account.AccountDescription + "',Address1='" + Account.Address1 + "', Address2='" + Account.Address2 + "' ,Address3='" + Account.Address3 + "',CountryCode=" + Account.CountryCode + ",ContactName='" + Account.ContactName + "',ContactTitle='" + Account.ContactTitle + "' where AccountId=" + Account.AccountId; int id = Util.doSQL(SQL); /* db.Entry(Account).Property(x => x.CreatedBy).IsModified = false; db.Entry(Account).Property(x => x.CreatedOn).IsModified = false; db.MSTR_Account.Add(Account); db.SaveChanges();*/ return RedirectToAction("Account"); } } catch (Exception ex) { //Log the error (uncomment dex variable name and add a line here to write a log. return View("InternalError", ex); } //for the server side validation var viewModel = new ViewModel.AccountViewModel { Account = db.MSTR_Account.Find(Account.AccountId), CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"), }; return View(viewModel); }//ActionEdit()