public ActionResult Login(string returnUrl) { ViewBag.ReturnUrl = returnUrl; LoginViewModel model = new LoginViewModel(); var compist = new NetStock.BusinessFactory.CompanyBO().GetList(); model.CompaniesList = new SelectList(compist, "CompanyCode", "CompanyName"); return(View(model)); }
public ActionResult SaveCompanyProfile(NetStock.Contract.Company company) { company.CreatedBy = Session["DEFAULTUSER"].ToString(); company.ModifiedBy = Session["DEFAULTUSER"].ToString(); company.IsActive = Utility.DEFAULTSTATUS; if (company.CompanyAddress.AddressId == 0 || company.CompanyAddress.AddressId == null) { company.CompanyAddress.AddressType = "Company"; company.CompanyAddress.SeqNo = 1; company.CompanyAddress.AddressLinkID = company.CompanyCode; } var result = new NetStock.BusinessFactory.CompanyBO().SaveCompany(company); return(RedirectToAction("CompanyProfile", "MasterData", new { companyCode = company.CompanyCode })); }
public ActionResult CompanyProfile(string companyCode) { Company company; if (companyCode != null) { company = new NetStock.BusinessFactory.CompanyBO().GetCompany(new Company { CompanyCode = companyCode }); } else { company = new Company(); } company.CountryList = Utility.GetCountryList(); //return View("CompanyProfile"); return(View(company)); }
public ActionResult Login(LoginViewModel model, string returnUrl) { if (!string.IsNullOrEmpty(Request.QueryString["companyCode"])) { var companyCode = Request.QueryString["companyCode"]; Session["CompanyCode"] = companyCode; var branchList = new NetStock.BusinessFactory.BranchBO().GetList().Where(x => x.CompanyCode == companyCode).ToList(); model.BranchList = new SelectList(branchList, "BranchID", "BranchName"); var compist = new NetStock.BusinessFactory.CompanyBO().GetList(); model.CompaniesList = new SelectList(compist, "CompanyCode", "CompanyName"); return(View("Login", model)); } if (!ModelState.IsValid) { return(RedirectToAction("Login")); } var lstUsers = new NetStock.BusinessFactory.UsersBO().GetList(); var result = true; var currentUser = lstUsers.Where(ur => ur.UserID.ToLower() == model.Email.ToLower() && ur.Password.ToLower() == model.Password.ToLower()).FirstOrDefault(); if (currentUser == null) { result = false; } if (currentUser != null) { FormsAuthentication.SetAuthCookie(currentUser.UserID, false); //Utility.DEFAULTUSER = currentUser.UserID; //Utility.DEFAULTUSERNAME = currentUser.UserName; //Utility.SsnBranch = model.BranchID; Session["DEFAULTUSER"] = currentUser.UserID; Session["DEFAULTUSERNAME"] = currentUser.UserName; Session["BranchId"] = model.BranchID; Session["BranchText"] = Request.Form["hdnBranchSelected"]; var roleCode = currentUser.RoleCode; Session["UserRoleCode"] = currentUser.RoleCode; var roleRights = new NetStock.BusinessFactory.RoleRightsBO() .GetList(roleCode); var securablesAll = (List <NetStock.Contract.Securables>)System.Web.HttpContext.Current.Application["AppSecurables"]; var securables = securablesAll.Join(roleRights, sec => sec.SecurableItem, rig => rig.SecurableItem, (sec, rig) => new { a = sec, b = rig }) .Select(x => new NetStock.Contract.Securables() { SecurableItem = x.a.SecurableItem, GroupID = x.a.GroupID, Description = x.a.Description, ActionType = x.a.ActionType, Link = x.a.Link, Icon = x.a.Icon }).ToList <NetStock.Contract.Securables>(); Session["SsnSecurables"] = securables; if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); return(View(model)); } }
public PartialViewResult GetCompanies() { var companyList = new NetStock.BusinessFactory.CompanyBO().GetList(); return(PartialView(companyList)); }