public ActionResult GetModuleList(string email)
        {
            var list = _iusercredentailservice.GetByEmail(email);

            if (list == null)
            {
                return(RedirectToAction("Add", "User"));
            }
            TempData["loginId"] = email;
            return(RedirectToAction("Update", "User"));
        }
        public ActionResult Create(MainApplication mainapp)
        {
            var shopmaster = _shopService.GetLastShop();
            int shopVal    = 0;
            int length     = 0;

            if (shopmaster != null)
            {
                shopVal = shopmaster.ShopId;
                shopVal = shopVal + 1;
                length  = shopVal.ToString().Length;
            }
            else
            {
                shopVal = 1;
                length  = 1;
            }
            string shopCode = _utilityService.getName("SH", length, shopVal);

            mainapp.ShopDetails.ShopCode   = shopCode;
            mainapp.ShopDetails.Status     = "Active";
            mainapp.ShopDetails.ModifiedOn = DateTime.Now;
            _shopService.Create(mainapp.ShopDetails);

            //SAVE SHOP IN USERCREDENTIAL AND MODULES
            Module         modulesdetails        = new Module();
            UserCredential usercredentialdetails = new UserCredential();

            modulesdetails.ModuleName       = mainapp.ShopDetails.ShopName;
            modulesdetails.ModuleRights     = "Add";
            modulesdetails.AssignRightsCode = shopCode;

            int LastRowPrimaryKey = _iIModuleService.GetLastRow().Id;
            int actualdashboardID = LastRowPrimaryKey + 1;

            modulesdetails.DashboardId = "D" + actualdashboardID;
            _iIModuleService.CreateModule(modulesdetails);

            var username      = HttpContext.Session["UserName"].ToString();
            var lastmodulerow = _iIModuleService.GetLastRow();

            //IF SUPERADMIN CREATE THE SHOP THEN MAKE THE ENTRY FOR SUPERADMIN ONLY..
            if (username == "SuperAdmin")
            {
                usercredentialdetails.ModuleId     = lastmodulerow.Id;
                usercredentialdetails.Modules      = mainapp.ShopDetails.ShopName;
                usercredentialdetails.ModuleRights = "Add";
                usercredentialdetails.UseName      = username;
                usercredentialdetails.Email        = UserEmail;
                usercredentialdetails.Status       = "add";
                _IUserCredentialService.CreateUserCredential(usercredentialdetails);

                string query = "GetUsersEmail";
                var    list  = _shopService.GetUserEmails(query);
                foreach (var data in list)
                {
                    var userdetails = _IUserCredentialService.GetByEmail(data.Email);
                    usercredentialdetails.ModuleId         = lastmodulerow.Id;
                    usercredentialdetails.Modules          = mainapp.ShopDetails.ShopName;
                    usercredentialdetails.ModuleRights     = "Add";
                    usercredentialdetails.UseName          = userdetails.UseName;
                    usercredentialdetails.Email            = data.Email;
                    usercredentialdetails.Status           = "";
                    usercredentialdetails.AssignRightsCode = shopCode;
                    _IUserCredentialService.CreateUserCredential(usercredentialdetails);
                }
            }
            //IF ANY OTHER EMPLOYEE CREATE THE SHOP THEN MAKE THE ENTRY FOR SUPERADMIN + EMPLOYEE..
            else
            {
                //IF EXCEPT SUPERADMIN ADD SHOP THEN IT WELL DISPLAY ALL EMPLOYEE IN USERCREDENTIAL
                string query = "GetUsersEmail";
                var    list  = _shopService.GetUserEmails(query);
                foreach (var data in list)
                {
                    var userdetails = _IUserCredentialService.GetByEmail(data.Email);
                    usercredentialdetails.ModuleId         = lastmodulerow.Id;
                    usercredentialdetails.Modules          = mainapp.ShopDetails.ShopName;
                    usercredentialdetails.ModuleRights     = "Add";
                    usercredentialdetails.UseName          = userdetails.UseName;
                    usercredentialdetails.Email            = data.Email;
                    usercredentialdetails.Status           = "";
                    usercredentialdetails.AssignRightsCode = shopCode;
                    _IUserCredentialService.CreateUserCredential(usercredentialdetails);
                }

                usercredentialdetails.AssignRightsCode = null;
                usercredentialdetails.Status           = "add";
                usercredentialdetails.UseName          = "SuperAdmin";
                usercredentialdetails.Email            = "*****@*****.**";
                _IUserCredentialService.CreateUserCredential(usercredentialdetails);
            }
            var lastrow = _shopService.GetLastShop();
            var ShopId  = Encode(lastrow.ShopId.ToString());

            return(RedirectToAction("CreateDetails/" + ShopId, "Shop"));
        }
Exemple #3
0
        public ActionResult Create(MainApplication mainapp)
        {
            MainApplication model = new MainApplication()
            {
                GodownDetails = new GodownMaster(),
            };
            var details = _godownService.getGodownLast();
            int lastid  = 0;
            int length  = 0;

            if (details != null)
            {
                lastid = details.GodownId;
                lastid = lastid + 1;
                length = lastid.ToString().Length;
            }
            else
            {
                lastid = 1;
                length = 1;
            }
            string Godowncode = _utilityService.getName("GD", length, lastid);

            mainapp.GodownDetails.Status     = "Active";
            mainapp.GodownDetails.ModifiedOn = DateTime.Now;
            int empid   = Convert.ToInt32(mainapp.GodownDetails.EmpName);
            var emplist = _employeemasterService.getEmpById(empid);

            mainapp.GodownDetails.EmpName = emplist.Name;
            _godownService.CreateGodown(mainapp.GodownDetails);
            mainapp.GodownAddressDetails.GdCode = Godowncode;
            _godownaddresService.CreateGoDown(mainapp.GodownAddressDetails);
            var GodownDetails = _godownService.getGodownLast();

            //SAVE SHOP IN USERCREDENTIAL AND MODULES
            Module         modulesdetails        = new Module();
            UserCredential usercredentialdetails = new UserCredential();

            modulesdetails.ModuleName       = mainapp.GodownDetails.GodownName;
            modulesdetails.ModuleRights     = "Add";
            modulesdetails.AssignRightsCode = Godowncode;

            int LastRowPrimaryKey = _iIModuleService.GetLastRow().Id;
            int actualdashboardID = LastRowPrimaryKey + 1;

            modulesdetails.DashboardId = "D" + actualdashboardID;
            _iIModuleService.CreateModule(modulesdetails);

            var username      = HttpContext.Session["UserName"].ToString();
            var lastmodulerow = _iIModuleService.GetLastRow();

            if (username == "SuperAdmin")
            {
                usercredentialdetails.ModuleId     = lastmodulerow.Id;
                usercredentialdetails.Modules      = mainapp.GodownDetails.GodownName;
                usercredentialdetails.ModuleRights = "Add";
                usercredentialdetails.UseName      = username;
                usercredentialdetails.Email        = UserEmail;
                usercredentialdetails.Status       = "add";
                _IUserCredentialService.CreateUserCredential(usercredentialdetails);

                string query = "GetUsersEmail";
                var    list  = _godownService.GetUserEmails(query);
                foreach (var data in list)
                {
                    var userdetails = _IUserCredentialService.GetByEmail(data.Email);
                    usercredentialdetails.ModuleId         = lastmodulerow.Id;
                    usercredentialdetails.Modules          = mainapp.GodownDetails.GodownName;
                    usercredentialdetails.ModuleRights     = "Add";
                    usercredentialdetails.UseName          = userdetails.UseName;
                    usercredentialdetails.Email            = data.Email;
                    usercredentialdetails.Status           = "";
                    usercredentialdetails.AssignRightsCode = Godowncode;
                    _IUserCredentialService.CreateUserCredential(usercredentialdetails);
                }
            }
            else
            {
                //IF EXCEPT SUPERADMIN ADD GODOWN THEN IT WELL DISPLAY ALL EMPLOYEE IN USERCREDENTIAL
                string query = "GetUsersEmail";
                var    list  = _godownService.GetUserEmails(query);
                foreach (var data in list)
                {
                    var userdetails = _IUserCredentialService.GetByEmail(data.Email);
                    usercredentialdetails.ModuleId         = lastmodulerow.Id;
                    usercredentialdetails.Modules          = mainapp.GodownDetails.GodownName;
                    usercredentialdetails.ModuleRights     = "Add";
                    usercredentialdetails.UseName          = userdetails.UseName;
                    usercredentialdetails.Email            = data.Email;
                    usercredentialdetails.Status           = "";
                    usercredentialdetails.AssignRightsCode = Godowncode;
                    _IUserCredentialService.CreateUserCredential(usercredentialdetails);
                }
                usercredentialdetails.AssignRightsCode = null;
                usercredentialdetails.Status           = "add";
                usercredentialdetails.UseName          = "SuperAdmin";
                usercredentialdetails.Email            = "*****@*****.**";
                _IUserCredentialService.CreateUserCredential(usercredentialdetails);
            }
            var Id       = _godownService.getGodownLast().GodownId;
            var GodownId = Encode(Id.ToString());

            return(RedirectToAction("CreateDetails/" + GodownId, "Godown"));
        }