public IActionResult Edit(Logica.Models.BindingModels.ProjectsEditBindingModel model)
        {
            if (ModelState.IsValid)
            {
                Logica.BL.Projects projects = new Logica.BL.Projects();

                projects.UpdateProjects(model.Id, model.Title,
                                        model.Details,
                                        model.ExpectedCompletionDate);

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
예제 #2
0
        public ActionResult Edit(int?id)
        {
            Logica.BL.Projects projects = new Logica.BL.Projects();
            var project = projects.GetProjects(id, null).FirstOrDefault();

            var projectBindinModel = new Logica.Models.BindingModels.ProjectsEditBindingModel
            {
                Id      = project.Id,
                Title   = project.Title,
                Details = project.Details,
                ExpectedCompletionDate = project.ExpectedCompletionDate
            };

            return(View(projectBindinModel));
        }
예제 #3
0
        public ActionResult Edit(Logica.Models.BindingModels.ProjectsEditBindingModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Logica.BL.Projects projects = new Logica.BL.Projects();
                    projects.UpdateProjects(model.Id,
                                            model.Title,
                                            model.Details,
                                            model.ExpectedCompletionDate);
                }
                else
                {
                    return(Json(new Logica.Models.ViewModels.ResponseViewModel
                    {
                        IsSuccessful = false,
                        Errors = ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage).ToList()
                    }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new
                {
                    IsSuccessful = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new Logica.Models.ViewModels.ResponseViewModel
                {
                    IsSuccessful = false,
                    Errors = new List <string> {
                        ex.Message
                    }
                }, JsonRequestBehavior.AllowGet));
            }
        }