コード例 #1
0
        public async Task <ActionResult> Register(RegisterViewModel model, string role = "")
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser()
                {
                    UserName = model.UserName, organisation = model.organisation
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    string id = new helpDescEntities().AspNetUsers.Single(r => r.UserName == model.UserName).Id;
                    if (role == "")
                    {
                        UserManager.AddToRole(id, "Subadmin");
                    }
                    else
                    {
                        UserManager.AddToRole(id, role);
                    }
                    return(RedirectToAction("Organisation", "Admin"));
                }
                else
                {
                    AddErrors(result);
                }
            }
            helpDescEntities db = new helpDescEntities();

            ViewBag.organisation = new SelectList(db.Organisations.ToList(), "id", "org_name");
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
コード例 #2
0
        public static string OrganisationName(string name)
        {
            helpDescEntities db       = new helpDescEntities();
            string           org_name = db.Organisations.Find(db.AspNetUsers.Single(r => r.UserName == name).organisation).org_name;

            return(org_name);
        }
コード例 #3
0
        public ActionResult Register()
        {
            helpDescEntities db = new helpDescEntities();

            ViewBag.organisation = new SelectList(db.Organisations.ToList(), "id", "org_name");
            return(View());
        }
コード例 #4
0
        public async Task <ActionResult> Register(RegisterViewModel model, int role_id)
        {
            int org = (int)db.AspNetUsers.Single(e => e.UserName == User.Identity.Name).organisation;

            if (ModelState.IsValid && (role_id == 1 || role_id == 2))
            {
                var user = new ApplicationUser()
                {
                    UserName = model.UserName, organisation = org
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    string id = new helpDescEntities().AspNetUsers.Single(r => r.UserName == model.UserName).Id;
                    if (role_id == 1)
                    {
                        UserManager.AddToRole(id, "Moderator");
                    }
                    if (role_id == 2)
                    {
                        UserManager.AddToRole(id, "QAAnswer");
                    }
                    return(RedirectToAction("Index", "Organisation"));
                }
                else
                {
                    AddErrors(result);
                }
            }
            ViewBag.organisation = new SelectList(db.Organisations.Where(r => r.id == org).ToList(), "id", "org_name", org);
            return(View(model));
        }
コード例 #5
0
        public static int NewQACount(string UserName)
        {
            helpDescEntities db = new helpDescEntities();
            var org_id          = db.AspNetUsers.Single(r => r.UserName == UserName).organisation;

            return(db.QAs.Where(r => r.org_id == org_id).Where(r => r.answer_date == null || r.answer == null || r.answer == "").Count());
        }
コード例 #6
0
        public static bool IsInRoleUserQA(string answer_user_id, string username)
        {
            helpDescEntities db = new helpDescEntities();
            var user            = db.AspNetUsers.Single(r => r.UserName == username);

            if (user.Id == answer_user_id)
            {
                return(true);
            }

            return(false);
        }
コード例 #7
0
        public static int isInCompanyUser(int org_id, string UserName)
        {
            helpDescEntities db = new helpDescEntities();

            if (db.AspNetUsers.Where(r => r.organisation == org_id).Where(r => r.UserName == UserName).Count() > 0)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
コード例 #8
0
        public static int NewComplainCount()
        {
            helpDescEntities db = new helpDescEntities();

            return(db.Complains.Where(r => r.status_id == 1).Count());
        }
コード例 #9
0
        public static string OrganisationServiceType(string name)
        {
            helpDescEntities db = new helpDescEntities();

            return(db.Organisations.Find(db.AspNetUsers.Single(r => r.UserName == name).organisation).service_type);
        }