Ejemplo n.º 1
0
        public ActionResult DeleteBranch(short branchID)
        {
            var result = false;

            string message = string.Empty;

            try
            {
                result = new NetStock.BusinessFactory.BranchBO().DeleteBranch(new Branch {
                    BranchID = branchID
                });

                TempData["isSaved"] = result;

                if (result)
                {
                    TempData["resultMessage"] = string.Format("Branch [{0}] Deleted Successfully", branchID);
                }
                else
                {
                    TempData["resultMessage"] = "Unable to DELETE the Record!";
                }
            }
            catch (Exception ex)
            {
                TempData["isSaved"]       = false;
                TempData["resultMessage"] = string.Format("Error Occurred {0}", ex.Message.ToString());
                ModelState.AddModelError("Error", ex.Message);
            }
            return(RedirectToAction("BranchProfile", "MasterData"));
        }
Ejemplo n.º 2
0
        public static IEnumerable <SelectListItem> GetBranchList()
        {
            var branchList = new NetStock.BusinessFactory.BranchBO().GetList();



            var selectList = branchList.Select(c =>
                                               new SelectListItem
            {
                Value = c.BranchID.ToString(),
                Text  = c.BranchCode
            });

            return(new SelectList(selectList, "Value", "Text"));
        }
Ejemplo n.º 3
0
        public ActionResult SaveBranchProfile(NetStock.Contract.Branch branch)
        {
            branch.CreatedBy  = Session["DEFAULTUSER"].ToString();
            branch.ModifiedBy = Session["DEFAULTUSER"].ToString();
            branch.IsActive   = Utility.DEFAULTSTATUS;

            if (branch.BranchAddress.AddressId == 0 || branch.BranchAddress.AddressId == null)
            {
                branch.BranchAddress.AddressType   = "Branch";
                branch.BranchAddress.SeqNo         = 1;
                branch.BranchAddress.IsActive      = true;
                branch.BranchAddress.AddressLinkID = branch.BranchCode;
            }
            var result = new NetStock.BusinessFactory.BranchBO().SaveBranch(branch);

            return(RedirectToAction("BranchProfile", "MasterData", new { companyCode = branch.CompanyCode, branchCode = branch.BranchCode }));
        }
Ejemplo n.º 4
0
        public ActionResult BranchProfile(string companyCode, string branchCode)
        {
            var branchprofile = new NetStock.Contract.Branch();

            branchprofile.CompanyCode = companyCode;

            if (branchCode != "NEW")
            {
                branchprofile = new NetStock.BusinessFactory.BranchBO().GetBranch(new NetStock.Contract.Branch {
                    BranchCode = branchCode
                });
            }

            if (branchprofile == null)
            {
                branchprofile = new NetStock.Contract.Branch();
            }

            branchprofile.CountryList = Utility.GetCountryList();

            return(View(branchprofile));
        }
Ejemplo n.º 5
0
        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));
            }
        }
Ejemplo n.º 6
0
        public JsonResult GetBranchList(string companyCode)
        {
            var brancList = new NetStock.BusinessFactory.BranchBO().GetList().Where(x => x.CompanyCode == companyCode).ToList();

            return(Json(brancList, JsonRequestBehavior.AllowGet));
        }