Beispiel #1
0
 public ActionResult Add(AdminUserVM model)
 {
     if (rpadminuser.Any(x => x.Email == model.Email))
     {
         ViewBag.IslemDurum = EnumIslemDurum.AdminMevcut;
         GetRoles();
         return(View(model));
     }
     else
     {
         if (ModelState.IsValid)
         {
             AdminUser entity = new AdminUser
             {
                 FullName = model.FullName,
                 Email    = model.Email,
                 Password = model.Password,
                 Roles    = model.Role + ";"
             };
             rpadminuser.Add(entity);
             ViewBag.IslemDurum = EnumIslemDurum.Basarili;
             ModelState.Clear();
         }
         else
         {
             ViewBag.IslemDurum = EnumIslemDurum.ValidationHata;
         }
         GetRoles();
         return(View(model));
     }
 }
Beispiel #2
0
 public ActionResult Edit(AdminUserVM model)
 {
     if (rpadminuser.Any(x => x.Email == model.Email && x.ID != model.ID))
     {
         ViewBag.IslemDurum = EnumIslemDurum.AdminMevcut;
         GetRoles();
         return(View(model));
     }
     else
     {
         if (ModelState.IsValid)
         {
             AdminUser entity = rpadminuser.Find(model.ID);
             string[]  roles  = entity.Roles.Split(';');
             entity.FullName   = model.FullName;
             entity.Email      = model.Email;
             entity.Password   = model.Password;
             entity.UpdateDate = DateTime.Now;
             if (!roles.Contains(model.Role))
             {
                 entity.Roles = model.Role + ";";
             }
             rpadminuser.SaveChanges();
             ViewBag.IslemDurum = EnumIslemDurum.Basarili;
         }
         else
         {
             ViewBag.IslemDurum = EnumIslemDurum.ValidationHata;
         }
         GetRoles();
         return(View(model));
     }
 }
        public IActionResult Add(AdminUserVM model, int[] rolearray)
        {
            if (ModelState.IsValid)
            {
                AdminUser adminUser = new AdminUser();
                adminUser.Name     = model.Name;
                adminUser.SurName  = model.SurName;
                adminUser.Email    = model.Email;
                adminUser.Password = model.Password;

                _bookcontext.AdminUsers.Add(adminUser);
                _bookcontext.SaveChanges();

                string rolenames = "";

                foreach (var item in rolearray)
                {
                    rolenames = rolenames + item.ToString() + ";";
                }
                adminUser.Role = rolenames;

                _bookcontext.SaveChanges();

                return(RedirectToAction("Index", "AdminUser"));
            }

            else
            {
                return(View());
            }
        }
Beispiel #4
0
        public ActionResult AddAdminUser(AdminUserVM model)
        {
            AdminUser entity = new AdminUser();

            entity.EMail    = model.EMail.ToLower();
            entity.Password = model.Password;

            AdminUserManager.AddAdminUser(entity);
            return(View());
        }
        public IActionResult Add()
        {
            AdminUserVM     model = new AdminUserVM();
            List <EnumRole> role  = new List <EnumRole>();

            role = Enum.GetValues(typeof(EnumRole))
                   .Cast <EnumRole>()
                   .ToList();
            model.roles = role;

            return(View(model));
        }
Beispiel #6
0
        public ActionResult UpdateAdmin(int id)
        {
            AdminUser   adminuser = db.AdminUsers.FirstOrDefault(q => q.id == id);
            AdminUserVM model     = new AdminUserVM()
            {
                ID       = adminuser.id,
                EMail    = adminuser.email,
                Password = adminuser.password,
                Name     = adminuser.name,
                Surname  = adminuser.surname,
            };

            return(View(model));
        }
        //[RoleControl(EnumRole.AdmminUserEdit)]

        public IActionResult Edit(int id)
        {
            AdminUser   adminUser = _context.AdminUsers.FirstOrDefault(x => x.ID == id);
            AdminUserVM model     = new AdminUserVM();

            model.id              = adminUser.ID;
            model.name            = adminUser.Name;
            model.surname         = adminUser.SurName;
            model.email           = adminUser.EMail;
            model.password        = adminUser.Password;
            model.confirmpassword = adminUser.Password;

            return(View(model));
        }
Beispiel #8
0
        public ActionResult Edit(int id)
        {
            var         entity = rpadminuser.Find(id);
            AdminUserVM model  = new AdminUserVM
            {
                FullName = entity.FullName,
                Email    = entity.Email,
                Password = entity.Password,
                Role     = entity.Roles.Replace(";", "")
            };

            GetRoles();
            return(View(model));
        }
        public IActionResult Add()
        {
            List <RolesVM> roles     = new List <RolesVM>();
            EnumRoles      enumRoles = new EnumRoles();
            string         rolid     = Convert.ToInt32(enumRoles).ToString();
            string         rolname   = Convert.ToString(enumRoles);

            List <int> rolidd = Enum.GetValues(typeof(EnumRoles)).Cast <EnumRoles>().Cast <int>().ToList();
            //string[] rolnamee = Enum.GetNames(typeof(EnumRoles));

            AdminUserVM model = new AdminUserVM();

            return(View(model));
        }
 public ActionResult ManageVolunteer(int id, string excMsg)
 {
     try
     {
         ViewBag.status = (string.IsNullOrEmpty(excMsg) ? null : excMsg);
         ReturnStatus rs = Repository.GetAdminViewOfUser(id);
         AdminUserVM  vm = (rs.errorCode == ReturnStatus.ALL_CLEAR) ? (AdminUserVM)rs.data : new AdminUserVM();
         return(View(vm));
     }
     catch
     {
         return(View("Error"));
     }
 }
        public IActionResult Detail(int id)
        {
            AdminUser adminuser = _context.AdminUsers.FirstOrDefault(x => x.ID == id);

            AdminUserVM model = new AdminUserVM();

            model.Name     = adminuser.Name;
            model.Surname  = adminuser.Surname;
            model.EMail    = adminuser.Email;
            model.Password = adminuser.Password;
            model.Roles    = adminuser.Roles;


            return(View(model));
        }
        public IActionResult Edit(AdminUserVM model)
        {
            AdminUser adminuser = _context.AdminUsers.FirstOrDefault(x => x.ID == model.ID);

            if (ModelState.IsValid)
            {
                adminuser.Name     = model.Name;
                adminuser.Surname  = model.Surname;
                adminuser.Email    = model.EMail;
                adminuser.Password = model.Password;
                adminuser.Roles    = model.Roles;

                _context.SaveChanges();
                return(View(model));
            }
            return(RedirectToAction("Index", "AdminUser"));
        }
        //[RoleControl(EnumRole.AdminUserAdd)]
        public IActionResult Add()
        {
            List <EnumRole> model = new List <EnumRole>();

            AdminUserVM model2 = new AdminUserVM();

            model = Enum.GetValues(typeof(EnumRole))
                    .Cast <EnumRole>().ToList();


            //model.Add(EnumRole.AdminUserAdd);
            //model.Add(EnumRole.AdminUserList);
            model2.enumRoles = model;


            return(View(model2));
        }
        public IActionResult Add(AdminUserVM model)
        {
            if (ModelState.IsValid)
            {
                AdminUser adminuser = new AdminUser();
                adminuser.Name     = model.Name;
                adminuser.Surname  = model.Surname;
                adminuser.Email    = model.EMail;
                adminuser.Password = model.Password;
                //adminuser.Roles = model.Roles;
                _context.AdminUsers.Add(adminuser);
                _context.SaveChanges();
                //return RedirectToAction("Index", "AdminUser");
                return(Redirect("/AdminArea/AdminUser/Index/"));
            }

            return(View());
        }
        public ActionResult AdminEditUser(int id)
        {
            try
            {
                ReturnStatus rs       = Repository.GetAdminViewOfUser(id);
                UserInfo     userInfo = new UserInfo();
                if (rs.errorCode == ReturnStatus.ALL_CLEAR)
                {
                    AdminUserVM vm = (AdminUserVM)rs.data;
                    userInfo = vm.userInfo;
                }

                return(PartialView("_AdminEditVolunteer", userInfo));
            }
            catch
            {
                return(View("_Error"));
            }
        }
        public IActionResult Add(AdminUserVM model, int[] roles)
        {
            if (ModelState.IsValid)
            {
                AdminUser adminUser = new AdminUser();
                adminUser.Name     = model.name;
                adminUser.SurName  = model.surname;
                adminUser.EMail    = model.email;
                adminUser.Password = model.password;

                _context.AdminUsers.Add(adminUser);
                _context.SaveChanges();

                //int AdminUserID = adminUser.ID;
                //foreach (var item in roles)
                //{
                //    adminUser.ID = AdminUserID;
                //    adminUser.RoleID = item.ToString();

                //    _context.SaveChanges();


                //}

                string rolenames = " ";

                foreach (var item in roles)
                {
                    rolenames = rolenames + item.ToString() + ";";
                }
                adminUser.Roles = rolenames;

                _context.SaveChanges();



                return(RedirectToAction("Index", "AdminUser"));
            }
            else
            {
                return(View());
            }
        }
Beispiel #17
0
 public ActionResult UpdateAdmin(AdminUserVM model)
 {
     if (ModelState.IsValid)
     {
         AdminUser adminuser = db.AdminUsers.FirstOrDefault(i => i.id == model.ID);
         adminuser.name     = model.Name;
         adminuser.surname  = model.Surname;
         adminuser.email    = model.EMail;
         adminuser.password = Encryptor.MD5Hash(model.Password);
         db.SaveChanges();
         ViewBag.IslemDurum = EnumIslemDurum.Success;
         return(View());
     }
     else
     {
         ViewBag.IslemDurum = EnumIslemDurum.ValidationError;
         return(View());
     }
 }
        public ActionResult AddAdminUser(AdminUserVM model)
        {
            if (ModelState.IsValid)
            {
                AdminUser post = new AdminUser();
                post.EMail    = model.EMail;
                post.Password = model.Password;

                db.AdminUsers.Add(post);
                db.SaveChanges();
                ViewBag.IslemDurum = 1;
                return(View());
            }
            else
            {
                ViewBag.IslemDurum = 2;
                return(View());
            }
        }
        public IActionResult Edit(AdminUserVM model)
        {
            AdminUser adminUser = _context.AdminUsers.FirstOrDefault(x => x.ID == model.id);

            if (ModelState.IsValid)
            {
                adminUser.Name       = model.name;
                adminUser.SurName    = model.surname;
                adminUser.EMail      = model.email;
                adminUser.Password   = model.password;
                adminUser.UpdateDate = model.updatedate;

                _context.SaveChanges();
                return(RedirectToAction("Index", "AdminUser"));
            }
            else
            {
                return(View());
            }
        }
        public ActionResult UpdateAdminUser(AdminUserVM model)
        {
            //güncellenecek kategori yakalanır ve yeni verilerie update edilir
            if (ModelState.IsValid)
            {
                AdminUser admin = db.AdminUsers.FirstOrDefault(x => x.ID == model.ID);
                admin.EMail    = model.EMail;
                admin.Password = model.Password;


                db.SaveChanges();
                ViewBag.IslemDurum = 1;
                return(View());
            }
            else
            {
                ViewBag.IslemDurum = 1;
                return(View());
            }
        }
Beispiel #21
0
        public ActionResult AddAdmin(AdminUserVM model)
        {
            //aynı emaile sahip bir admin varsa ekleme!

            if (ModelState.IsValid)
            {
                bool adminVarMi = db.AdminUsers.Any(q => q.email == model.EMail);

                //AdminUser admin = db.AdminUsers.FirstOrDefault(q => q.email == model.EMail);

                if (adminVarMi)
                {
                    ViewBag.IslemDurum = EnumIslemDurum.EMailError;
                }
                else
                {
                    AdminUser adminuser = new AdminUser();
                    adminuser.name     = model.Name;
                    adminuser.surname  = model.Surname;
                    adminuser.password = Encryptor.MD5Hash(model.Password);
                    adminuser.email    = model.EMail;

                    db.AdminUsers.Add(adminuser);
                    db.SaveChanges();

                    ViewBag.IslemDurum = EnumIslemDurum.Success;
                }



                return(View());
            }
            else
            {
                ViewBag.IslemDurum = EnumIslemDurum.ValidationError;
                return(View());
            }
        }
Beispiel #22
0
        public IActionResult Add(AdminUserVM model)
        {
            if (ModelState.IsValid)
            {
                AdminUser adminUser = new AdminUser();

                adminUser.EMail    = model.EMail;
                adminUser.Name     = model.Name;
                adminUser.Surname  = model.Surname;
                adminUser.Password = model.Password;



                _vatancontext.AdminUsers.Add(adminUser);
                _vatancontext.SaveChanges();
            }
            else
            {
                return(View());
            }

            return(RedirectToAction("Index", "Login"));
        }
        public ActionResult AddAdminUser(AdminUserVM model)
        {
            if (ModelState.IsValid)
            {
                if (db.AdminUsers.Any(x => x.EMail == model.EMail))
                {
                    ViewBag.IslemDurum = 2;
                    return(View());
                }
                AdminUser adminuser = new AdminUser();
                adminuser.EMail    = model.EMail;
                adminuser.Password = model.Password;

                db.AdminUsers.Add(adminuser);
                db.SaveChanges();
                ViewBag.IslemDurum = 1;
                return(View());
            }
            else
            {
                ViewBag.IslemDurum = 3;
                return(View());
            }
        }