示例#1
0
        public ActionResult EditAdmin(string id)
        {
            if (!user.IsAdmin())
            {
                return(View("Error"));
            }
            int id_admin = Convert.ToInt32(id);

            try
            {
                admin admin = Model.GetAdmin(id_admin);
                Model.UpdateLastSeen("Sửa Admin " + admin.name, Url.Action("EditAdmin/" + id));
                return(View(admin));
            } catch (Exception)
            {
                return(View("Error"));
            }
        }
示例#2
0
 private async void SignInExecute(object obj)
 {
     LoginStatus = string.Empty;
     if (CheckUsernameAndPassword())
     {
         User        a    = new User();
         ContentPage view = new ContentPage();
         if (UserType == StartViewModel.AdminUserType)
         {
             a = await AdminDA.GetAdmin(User);
         }
         else if (UserType == StartViewModel.RecyclerUserType)
         {
             a = await RecyclerDA.GetRecycler(User);
         }
         else
         {
             a = await CollectorDA.GetCollector(User);
         }
         if (a != null)
         {
             if (a.Password == Password)
             {
                 if (Application.Current.Properties.ContainsKey("loggedIn"))
                 {
                     Application.Current.Properties["loggedIn"] = 1;
                 }
                 else
                 {
                     Application.Current.Properties.Add("loggedIn", 1);
                     await Application.Current.SavePropertiesAsync();
                 }
                 if (a is Recycler)
                 {
                     RecyclerViewModel.Recycler = (Recycler)a;
                     view = new Views.RecyclerMainView();
                 }
                 else if (a is Collector)
                 {
                     CollectorViewModel.Collector = (Collector)a;
                     view = new Views.CollectorMainView();
                 }
                 else
                 {
                     MainViewModel.Admin = a;
                     view = new Views.AdminMainView();
                 }
                 Username = string.Empty;
                 Password = string.Empty;
                 Application.Current.MainPage = new NavigationPage(view);
             }
             else
             {
                 Application.Current.Properties["loggedIn"] = 0;
                 LoginStatus = "Username or password is wrong!";
             }
         }
         else
         {
             LoginStatus = "Username or password not found!";
         }
     }
 }