Exemplo n.º 1
0
        public IHttpResponse Edit(EditIssueViewModel model)
        {
            var issue = this.Db.Issues.FirstOrDefault(i => i.Id == model.Id);

            if (issue == null)
            {
                return(this.BadRequestError("Issue do not exist"));
            }

            if (issue.User.Username != this.User.Username && this.User.Role != "Admin")
            {
                return(this.Redirect("/Issues/All"));
            }

            issue.Name     = model.Name;
            issue.Status   = Enum.Parse <Status>(model.Status);
            issue.Priority = Enum.Parse <Priority>(model.Priority);

            this.Db.SaveChanges();

            return(this.Redirect("/Issues/All"));
        }
Exemplo n.º 2
0
        public IHttpResponse Edit(int id)
        {
            var issue = this.Db.Issues.FirstOrDefault(i => i.Id == id);

            if (issue == null)
            {
                return(this.BadRequestError("Issue do not exist"));
            }

            var statusValues   = Enum.GetValues(typeof(Status));
            var priorityValues = Enum.GetValues(typeof(Priority));

            var model = new EditIssueViewModel()
            {
                OptionStatusValues    = statusValues,
                OptionsPriorityValues = priorityValues,
                Id       = id,
                Status   = issue.Status.ToString(),
                Priority = issue.Priority.ToString(),
                Name     = issue.Name
            };

            return(this.View(model));
        }