コード例 #1
0
        public ActionResult Login(HospitalUser user)
        {
            if (ModelState.IsValid)
            {
                int UserId = user.UserID;
                ViewBag.UserID = new SelectList(db.Doctors, "Id", "FirstName", user.UserID);

                string password = user.Password.ToString();
                string userName = user.Doctor.FirstName.ToString();

                bool userValid = db.HospitalUsers.Any(u => u.UserID == UserId && u.Password == password);

                if (userValid)
                {
                    FormsAuthentication.SetAuthCookie(userName, false);


                    return(RedirectToAction("loggedin"));
                }
            }

            else
            {
                ModelState.AddModelError(" ", "ID and Password combination Error");
            }
            return(View());
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            HospitalUser hospitalUser = db.HospitalUsers.Find(id);

            db.HospitalUsers.Remove(hospitalUser);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "Id,UserID,Email,confirm_Email,Password")] HospitalUser hospitalUser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hospitalUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserID = new SelectList(db.Doctors, "Id", "FirstName", hospitalUser.UserID);
     return(View(hospitalUser));
 }
コード例 #4
0
        // GET: HospitalUsers/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HospitalUser hospitalUser = db.HospitalUsers.Find(id);

            if (hospitalUser == null)
            {
                return(HttpNotFound());
            }
            return(View(hospitalUser));
        }
コード例 #5
0
        // GET: HospitalUsers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HospitalUser hospitalUser = db.HospitalUsers.Find(id);

            if (hospitalUser == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserID = new SelectList(db.Doctors, "Id", "FirstName", hospitalUser.UserID);
            return(View(hospitalUser));
        }
コード例 #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            Toast.MakeText(this, "Hello", ToastLength.Long).Show();

            var btnLogin = FindViewById <Button>(Resource.Id.login);

            btnLogin.Click += (object sender, EventArgs e) =>
            {
                var name     = FindViewById <EditText>(Resource.Id.name).Text;
                var password = FindViewById <EditText>(Resource.Id.password).Text;

                HospitalUser user = new HospitalUser()
                {
                    Login    = name,
                    Password = password
                };

                var userJson = JsonConvert.SerializeObject(user);

                var messageError = "incorrect password or login";
                var response     = RestHttpClient.I.PostRequestRaw("http://hlp-hospital-api.azurewebsites.net/api/users", userJson);

                if (response.HttpResponseMessage.IsSuccessStatusCode)
                {
                    Intent nextActivity = new Intent(this, typeof(GeneratorActivity));
                    nextActivity.PutExtra("name", name);
                    StartActivity(nextActivity);
                }
                else
                {
                    Logger.LogError(this,
                                    response.HttpResponseMessage.StatusCode == HttpStatusCode.Forbidden
                            ? messageError
                            : "unexpected server error occured");
                }
            };
        }
コード例 #7
0
        public async Task <ActionResult> Register(RegisterViewModel Adminmodel, HospitalUserRegisterViewModel Hospitalmodel, EngineerUserRegisterViewModel Engineermodel)
        {
            ViewBag.Bool = false;
            if ((string)TempData["userNoo"] == "AdminUser")
            {
                ModelState.Remove("HospitalName");
                ModelState.Remove("YearsOfWork");
                ModelState.Remove("ExpertInInstruments");
                var user = new ApplicationUser {
                    City = Adminmodel.City, Province = Adminmodel.Province, PhoneNumber = Adminmodel.PhoneNumberr, NameAndLastName = Adminmodel.NameAndLastName, Email = Adminmodel.UserNamee, UserName = Adminmodel.UserNamee, userRole = (string)TempData["userNoo"]
                };
                if (ModelState.IsValid)
                {
                    var result = await UserManager.CreateAsync(user, Adminmodel.Password);

                    AddErrors(result);
                }

                if (ModelState.IsValid)
                {
                    var result = await UserManager.AddToRoleAsync(user.Id, user.userRole);

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    AddErrors(result);
                    if (ModelState.IsValid)
                    {
                        AdminUser adminuser = new AdminUser();
                        adminuser.NameAndLastName = user.NameAndLastName;
                        adminuser.City            = user.City;
                        adminuser.PhoneNumberr    = user.PhoneNumber;
                        adminuser.UserNamee       = user.UserName;
                        adminuser.Province        = user.Province;
                        APPAuthentication.AppAuthentication appAuthentication = new APPAuthentication.AppAuthentication(adminuser);
                        string x = appAuthentication.Registeration();
                        return(RedirectToAction("Index", "MyPanel"));
                    }
                    else
                    {
                        TempData["userNoo"] = "AdminUser";
                        ///////////////////////////////////////////////////////////////////////////////////
                        List <SelectListItem> list = new List <SelectListItem>();
                        foreach (var city in db.T_City)
                        {
                            list.Add(new SelectListItem()
                            {
                                Value = city.City_Name.ToString(), Text = city.City_Name.ToString()
                            });
                        }
                        ViewBag.Cities = list;
                        List <SelectListItem> listt = new List <SelectListItem>();
                        foreach (var state in db.T_State)
                        {
                            listt.Add(new SelectListItem()
                            {
                                Value = state.State_Name.ToString(), Text = state.State_Name.ToString()
                            });
                        }
                        ViewBag.Province = listt;
                        ////////////////////////////////////////////////////////////////////////////////////////////////
                        if (user.Province != null)
                        {
                            ViewBag.Cities = GetRelatedCity(user.Province);
                            return(PartialView("_Register"));
                        }
                        else
                        {
                            return(View("RegisterForAdmin"));
                        }
                    }
                }
                else
                {
                    //Returning Model For possible errors (Admin Model)
                    TempData["userNoo"] = "AdminUser";

                    ///////////////////////////////////////////////////////////////////////////////////////////////////////
                    List <SelectListItem> list = new List <SelectListItem>();
                    foreach (var city in db.T_City)
                    {
                        list.Add(new SelectListItem()
                        {
                            Value = city.City_Name.ToString(), Text = city.City_Name.ToString()
                        });
                    }
                    ViewBag.Cities = list;
                    List <SelectListItem> listt = new List <SelectListItem>();
                    foreach (var state in db.T_State)
                    {
                        listt.Add(new SelectListItem()
                        {
                            Value = state.State_Name.ToString(), Text = state.State_Name.ToString()
                        });
                    }
                    ViewBag.Province = listt;
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////
                    if (user.Province != null)
                    {
                        ViewBag.Cities = GetRelatedCity(user.Province);
                        return(PartialView("_Register"));
                    }
                    else
                    {
                        return(View("RegisterForAdmin"));
                    }
                }
            }
            else if ((string)TempData["userNoo"] == "HospitalUsers")
            {
                ModelState.Remove("ExpertInInstruments");
                ModelState.Remove("YearsOfWork");
                var user = new ApplicationUserForHospitals {
                    City = Hospitalmodel.City, Province = Hospitalmodel.Province, HospitalName = Hospitalmodel.HospitalName, NameAndLastName = Hospitalmodel.NameAndLastName, Email = Hospitalmodel.UserNamee, UserName = Hospitalmodel.UserNamee, PhoneNumber = Hospitalmodel.PhoneNumberr, userRole = (string)TempData["userNoo"]
                };
                if (ModelState.IsValid)
                {
                    var result = await UserManager.CreateAsync(user, Hospitalmodel.Password);

                    AddErrors(result);
                }

                if (ModelState.IsValid)
                {
                    var result = await UserManager.AddToRoleAsync(user.Id, user.userRole);

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    AddErrors(result);
                    if (ModelState.IsValid)
                    {
                        HospitalUser hospitaluser = new HospitalUser();
                        hospitaluser.City            = user.City;
                        hospitaluser.PhoneNumberr    = user.PhoneNumber;
                        hospitaluser.Province        = user.Province;
                        hospitaluser.UserNamee       = user.UserName;
                        hospitaluser.NameAndLastName = user.NameAndLastName;
                        hospitaluser.HospitalName    = user.HospitalName;
                        APPAuthentication.AppAuthentication appAuthentication = new APPAuthentication.AppAuthentication(hospitaluser);
                        string x = appAuthentication.Registeration();
                        return(RedirectToAction("Index", "MyPanel"));
                    }
                    else
                    {
                        TempData["userNoo"] = "HospitalUsers";
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////
                        List <SelectListItem> list = new List <SelectListItem>();
                        foreach (var city in db.T_City)
                        {
                            list.Add(new SelectListItem()
                            {
                                Value = city.City_Name.ToString(), Text = city.City_Name.ToString()
                            });
                        }
                        ViewBag.Cities = list;
                        List <SelectListItem> listt = new List <SelectListItem>();
                        foreach (var state in db.T_State)
                        {
                            listt.Add(new SelectListItem()
                            {
                                Value = state.State_Name.ToString(), Text = state.State_Name.ToString()
                            });
                        }
                        ViewBag.Province = listt;
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////
                        return(View("RegisterForHospital"));
                    }
                }
                else
                {
                    TempData["userNoo"] = "HospitalUsers";
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////
                    List <SelectListItem> list = new List <SelectListItem>();
                    foreach (var city in db.T_City)
                    {
                        list.Add(new SelectListItem()
                        {
                            Value = city.City_Name.ToString(), Text = city.City_Name.ToString()
                        });
                    }
                    ViewBag.Cities = list;
                    List <SelectListItem> listt = new List <SelectListItem>();
                    foreach (var state in db.T_State)
                    {
                        listt.Add(new SelectListItem()
                        {
                            Value = state.State_Name.ToString(), Text = state.State_Name.ToString()
                        });
                    }
                    ViewBag.Province = listt;
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////
                    return(View("RegisterForHospital"));
                }
            }
            else if ((string)TempData["userNoo"] == "EngineerUsers")
            {
                ModelState.Remove("HospitalName");
                var user = new ApplicationUserForEngineers {
                    City = Engineermodel.City, Province = Engineermodel.Province, ExpertInInstruments = Engineermodel.ExpertInInstruments, YearsOfWork = Engineermodel.YearsOfWork, NameAndLastName = Engineermodel.NameAndLastName, Email = Engineermodel.UserNamee, UserName = Engineermodel.UserNamee, PhoneNumber = Engineermodel.PhoneNumberr, userRole = (string)TempData["userNoo"]
                };
                if (ModelState.IsValid)
                {
                    var result = await UserManager.CreateAsync(user, Engineermodel.Password);

                    AddErrors(result);
                }
                if (ModelState.IsValid)
                {
                    var result = await UserManager.AddToRoleAsync(user.Id, user.userRole);

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    AddErrors(result);
                    if (ModelState.IsValid)
                    {
                        EngineerUser engineeruser = new EngineerUser();
                        engineeruser.NameAndLastName = user.NameAndLastName;
                        engineeruser.instruments     = user.ExpertInInstruments;
                        engineeruser.City            = user.City;
                        engineeruser.PhoneNumberr    = user.PhoneNumber;
                        engineeruser.Province        = user.Province;
                        engineeruser.UserNamee       = user.UserName;
                        APPAuthentication.AppAuthentication appAuthentication = new APPAuthentication.AppAuthentication(engineeruser);
                        string x = appAuthentication.Registeration();
                        return(RedirectToAction("Index", "MyPanel"));
                    }
                    else
                    {
                        TempData["userNoo"] = "EngineerUsers";
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////
                        List <SelectListItem> list = new List <SelectListItem>();
                        foreach (var city in db.T_City)
                        {
                            list.Add(new SelectListItem()
                            {
                                Value = city.City_Name.ToString(), Text = city.City_Name.ToString()
                            });
                        }
                        ViewBag.Cities = list;
                        List <SelectListItem> listt = new List <SelectListItem>();
                        foreach (var state in db.T_State)
                        {
                            listt.Add(new SelectListItem()
                            {
                                Value = state.State_Name.ToString(), Text = state.State_Name.ToString()
                            });
                        }
                        ViewBag.Province = listt;
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////
                        return(View("RegisterForEngineer"));
                    }
                }
                else
                {
                    //Returning Model For possible errors (Engineer Model)
                    TempData["userNoo"] = "EngineerUsers";
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////
                    List <SelectListItem> list = new List <SelectListItem>();
                    foreach (var city in db.T_City)
                    {
                        list.Add(new SelectListItem()
                        {
                            Value = city.City_Name.ToString(), Text = city.City_Name.ToString()
                        });
                    }
                    ViewBag.Cities = list;
                    List <SelectListItem> listt = new List <SelectListItem>();
                    foreach (var state in db.T_State)
                    {
                        listt.Add(new SelectListItem()
                        {
                            Value = state.State_Name.ToString(), Text = state.State_Name.ToString()
                        });
                    }
                    ViewBag.Province = listt;
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////
                    return(View("RegisterForEngineer"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #8
0
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            //var userDB = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IUserDb>();

            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameFName.Value))
                {
                    throw new Exception("First Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameLName.Value))
                {
                    throw new Exception("Last Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameEmail.Value))
                {
                    throw new Exception("Email field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameUName.Value))
                {
                    throw new Exception("User Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNamePhone.Value))
                {
                    throw new Exception("Phone No. field is required");
                }
                if (!string.IsNullOrWhiteSpace(DropDownRole.SelectedItem.Text) && !DropDownRole.SelectedItem.Text.Equals("SuperAdmin"))
                {
                    throw new Exception("SuperAdmin user role must be selected here");
                }
                string userName = TextBoxNameUName.Value.Trim();
                string superAdminHospitalName        = "SuperAdminHospital";
                IList <HospitalUser> adminUserList   = new HospitalUserDAO().RetrieveAdminUser(userName);
                IList <Hospital>     theHospitalList = new HospitalDAO().RetrieveByName(superAdminHospitalName);

                if (adminUserList.Count == 0)
                {
                    //create headquarters branch for user
                    Hospital hospital = new Hospital();
                    if (theHospitalList == null && theHospitalList.Count <= 0)
                    {
                        hospital.Name                 = "SuperAdminHospital";
                        hospital.Address              = "Mars";
                        hospital.PrimaryContactEmail  = "NONE";
                        hospital.PrimaryContactNumber = "NONE";
                        HospitalDAO.Save(hospital);
                    }

                    //User user =Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IUserDb>();
                    HospitalUser user = new HospitalUser();
                    user.FirstName   = TextBoxNameFName.Value;
                    user.LastName    = TextBoxNameLName.Value;
                    user.OtherNames  = TextBoxNameONames.Value;
                    user.Email       = TextBoxNameEmail.Value;
                    user.UserName    = TextBoxNameUName.Value;
                    user.Phone       = TextBoxNamePhone.Value;
                    user.UserRole    = (UserRole)Enum.Parse(typeof(UserRole), DropDownRole.SelectedValue);
                    user.TheHospital = (theHospitalList == null && theHospitalList.Count <= 0) ? hospital : theHospitalList.First();
                    //user.Branch.Id = branch.Id;
                    //user.Branch.BranchName = branch.BranchName;

                    HospitalUserLogic userLogic = new HospitalUserLogic();
                    user.Password     = userLogic.HashPassword(userLogic.CreatePassword());
                    user.IsFirstLogin = true;       //update this field to false once user changes password successfully

                    user.DateCreated = DateTime.Now;
                    HospitalDAO.Save(hospital);
                    userLogic.SendMail(user.Email, user.Password);
                    HospitalUserDAO.Save(user);
                    //Response.Redirect("../Start/Login.aspx");
                }

                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "UserName Already Exists!" + "', function(){});</script>", false);
                }


                TextBoxNameFName.Value  = String.Empty;
                TextBoxNameLName.Value  = String.Empty;
                TextBoxNameONames.Value = String.Empty;
                //BranchTextbox.Text = String.Empty;
                TextBoxNameEmail.Value = String.Empty;
                //RoleTextBox.Text = String.Empty;
                TextBoxNameUName.Value = String.Empty;
                TextBoxNamePhone.Value = String.Empty;

                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Admin Saved Successfully" + "', function(){location = '/Start/Login.aspx';});</script>", false);
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
コード例 #9
0
 public void Create(HospitalUser temperature)
 {
     throw new System.NotImplementedException();
 }