Пример #1
0
        public ActionResult SavePharmacist(Pharmacist m, String command)
        {
            // if id's are default, get actual id's for the (new) pharmacist
            // use sql to save pharmacist to db
            if (m.PharmacistId == 0)
            {
                m.Type = Models.User.UserType.Pharmacist;
                var phid = DatabaseUserService.Insert(m);
                m.UserId       = phid;
                m.PharmacistId = DatabasePharmacistService.Insert(m);
                var login = new Login();
                login.LoginToken = "";
                login.UserId     = m.UserId;
                login.SetPassword(Login.GetUniqueKey(32));
                DatabaseLoginService.Insert(login);
                EmailService.SendReset(m);
            }
            else
            {
                DatabaseUserService.Update(m);
                DatabasePharmacistService.Update(m);
            }

            if (DatabaseUserService.GetById((long)Session["user_id"]).Type == Models.User.UserType.PPOkAdmin)
            {
                return(RedirectToAction("AddorEditPharmacy", "PpokAdmin", new { id = m.PharmacyId }));
            }
            return(RedirectToAction("Admin", "Pharmacy"));
        }
Пример #2
0
        public string AddFakeLogin(long pid)
        {
            var pharmAdmin = new Pharmacist {
                FirstName  = "Pharma",
                LastName   = "cist",
                Phone      = "+19999999993",
                Email      = "*****@*****.**",
                PharmacyId = pid,
                UserId     = 1,
                IsAdmin    = true,
                Type       = Models.User.UserType.Pharmacist
            };

            pharmAdmin.UserId = DatabaseUserService.Insert(pharmAdmin);
            var login = new Login {
                LoginId    = 1,
                UserId     = pharmAdmin.UserId,
                LoginToken = ""
            };

            login.SetPassword("harambe");
            DatabaseLoginService.Insert(login);

            DatabasePharmacistService.Insert(pharmAdmin);

            var ppokAdmin = new User {
                LastName  = "dmin",
                FirstName = "PPOk A",
                Type      = Models.User.UserType.PPOkAdmin,
                Phone     = "+19999999998",
                Email     = "*****@*****.**"
            };

            ppokAdmin.UserId = DatabaseUserService.Insert(ppokAdmin);

            var login2 = new Login {
                UserId     = ppokAdmin.UserId,
                LoginToken = ""
            };

            login2.SetPassword("harambe");

            DatabaseLoginService.Insert(login2);

            return("sucess <br/> Pharm: username: [email protected] password: harambe <br/> Admin: username: [email protected] password: harambe");
        }