Ejemplo n.º 1
0
        public ActionResult Delete(int id)
        {
            var obj   = repositoryEvent.GetEvent(id);
            var model = new RoutViewModels();

            if (obj != null)
            {
                model.Controller = "Scheduler";
                model.Action     = "SaveDelete";
                model.Id         = id.ToString();
                model.Title      = "Delete";
                model.Data       = new HtmlString(
                    "Are you sure want to delete this event:</br>"
                    + obj.Start + " - " + obj.Title + "?"
                    );
            }
            else
            {
                model.Controller = "Scheduler";
                model.Action     = "Schedule";
                model.Id         = id.ToString();
                model.Title      = "Delete";
                model.Data       = new HtmlString("This event not found");
            }
            return(PartialView("ModalConfirm", model));
        }
Ejemplo n.º 2
0
        public ActionResult Delete(string id)
        {
            var user  = repositoryPeople.GetUser(id);
            var model = new RoutViewModels();

            if (user != null)
            {
                model.Controller = "Employees";
                model.Action     = "SaveDelete";
                model.Id         = id;
                model.Title      = "Delete";
                model.Data       = new HtmlString(
                    "Are you shure you want to delete this person - </br><strong>" + user.Email + "</strong>?"
                    );
            }
            else
            {
                model.Controller = "Employees";
                model.Action     = "Users";
                model.Id         = id;
                model.Title      = "Delete";
                model.Data       = new HtmlString(
                    "This user not found" + user.Email
                    );
            }
            return(PartialView("ModalConfirm", model));
        }
Ejemplo n.º 3
0
        public ActionResult SetPosition(string id)
        {
            var user  = repositoryPeople.GetUser(id);
            var model = new RoutViewModels
            {
                Controller = "Employees",
                Action     = "Users",
                Id         = id,
                Title      = "Position"
            };

            if (user != null)
            {
                if (user.EmailConfirmed == true)
                {
                    model.Controller = "Employees";
                    model.Action     = "SavePosition";
                    model.Id         = id;
                    model.Title      = "Position";
                    string htmlString   = "";
                    string check        = "";
                    var    userPosition = repositoryPeople.GetEmployee(id)
                                          ?.Positions.Select(p => p.Name)
                                          .ToList() ?? new List <string>();
                    var allPosition = context.Positions.Select(p => p.Name)
                                      .ToList() ?? new List <string>();
                    foreach (var item in allPosition)
                    {
                        check = "";
                        if (userPosition.Contains(item))
                        {
                            check = "checked";
                        }
                        htmlString +=
                            "<div class=\"form-check\">" +
                            $"<input id = \"{item}\" name=\"{item}\" type=\"checkbox\" {check} class=\"form-check-input\">" +
                            $"<label class=\"form-check-label\" for=\"{item}\" checked autocomplete=\"off\">{item}</label>" +
                            "</div>";
                    }
                    model.Data = new HtmlString(htmlString);
                }
                else
                {
                    model.Data = new HtmlString("<label>This person don't confirmed email.</label>");
                }
            }
            else
            {
                model.Data = new HtmlString("This user not found" + user.Email);
            }
            return(PartialView("ModalConfirm", model));
        }
Ejemplo n.º 4
0
        public ActionResult SetAccess(string id)
        {
            var userManager = new ApplicationUserManager(new UserStore <ApplicationUser>(context));
            var user        = repositoryPeople.GetUser(id);
            var model       = new RoutViewModels {
                Controller = "Employees",
                Action     = "Users",
                Id         = id,
                Title      = "Access"
            };

            if (user != null)
            {
                if (user.EmailConfirmed == true)
                {
                    model.Controller = "Employees";
                    model.Action     = "SaveAccess";
                    model.Id         = id;
                    model.Title      = "Access";

                    var    userRole   = userManager.GetRoles(id).ToList() ?? new List <string>();
                    var    allRoles   = context.Roles.Where(r => r.Name != "admin").Select(r => r.Name).ToList();
                    string htmlString = "";
                    foreach (var item in allRoles)
                    {
                        string check = "";
                        if (userRole.Contains(item))
                        {
                            check = "checked";
                        }
                        htmlString +=
                            "<div class=\"form-check\">" +
                            $"<input id = \"{item}\" name=\"{item}\" type=\"checkbox\" {check} class=\"form-check-input\">" +
                            $"<label class=\"form-check-label\" for=\"{item}\" checked autocomplete=\"off\">{item}</label>" +
                            "</div>";
                    }
                    model.Data = new HtmlString(htmlString);
                }
                else
                {
                    model.Data = new HtmlString("<label>This person don't confirmed email.</label>");
                }
            }
            else
            {
                model.Data = new HtmlString(
                    "This user not found" + user.Email
                    );
            }
            return(PartialView("ModalConfirm", model));
        }
Ejemplo n.º 5
0
        public ActionResult SaveDelete(RoutViewModels model)
        {
            int id;

            int.TryParse(model.Id, out id);
            if (id == 0)
            {
                return(RedirectToAction("Schedule"));
            }
            var ev = repositoryEvent.GetEvents().FirstOrDefault(e => e.Id == id);

            if (ev != null)
            {
                repositoryEvent.Delete(id);
            }
            return(RedirectToAction("Schedule"));
        }
Ejemplo n.º 6
0
 public ActionResult SaveDelete(RoutViewModels model)
 {
     repositoryPeople.Delete(model.Id);
     return(RedirectToAction("Users"));
 }