Ejemplo n.º 1
0
        public ActionResult AddReleaseInline(ReleaseModel model)
        {
            if (!ModelState.IsValid) return JsonView(ModelState.IsValid, "_AddReleaseInline", model);

            if (ProjectContext.TryAddRelease(model))
            {
                Context.SaveChanges();
            }
            else
            {
                AddModelErrors(ProjectContext.Errors);
            }

            return JsonView(ModelState.IsValid, "_AddReleaseInline", model);
        }
Ejemplo n.º 2
0
        public bool TryEditRelease(ReleaseModel model)
        {
            Release release;
            if (!Releases.TryGetById(model.Id, out release))
                throw new ApplicationException("release with id = " + model.Id + " was not found!");

            release.Name = model.Name;
            release.Description = model.Description;
            release.From = model.From;
            release.To = model.To;
            release.ProjectId = ProjectId;

            var releases = Releases.AsPredicateTrue()
                                   .And(x => x.Id != release.Id)
                                   .Evaluate();

            if (!releases.AnyOverlapsWith(release)) return true;

            Errors.Add(new Tuple<string, string>("from", "ReleaseOverlapedErrorKey"));
            Errors.Add(new Tuple<string, string>("to", "ReleaseOverlapedErrorKey"));

            return false;
        }
Ejemplo n.º 3
0
        public bool TryAddRelease(ReleaseModel model)
        {
            var release = new Release(model.Name, model.From, model.To, ProjectId)
            {
                Description = model.Description
            };

            if (Releases.AnyOverlapsWith(release))
            {
                Errors.Add(new Tuple<string, string>("from", "ReleaseOverlapedErrorKey"));
                Errors.Add(new Tuple<string, string>("to", "ReleaseOverlapedErrorKey"));

                return false;
            }

            Database.Releases.Add(release);

            return true;
        }
Ejemplo n.º 4
0
        public ActionResult Edit(ReleaseModel model)
        {
            if (!ModelState.IsValid) return View("EditRelease", model);

            if (ProjectContext.TryEditRelease(model))
            {
                Context.SaveChanges();
                return this.RedirectToAction(x => x.Index());
            }

            AddModelErrors(ProjectContext.Errors);
            return View("EditRelease", model);
        }
Ejemplo n.º 5
0
        public ActionResult Edit(long id)
        {
            Release release;
            if (!ProjectContext.Releases.TryGetById(id, out release))
                throw new ApplicationException("release with id = " + id + " was not found!");

            var model = new ReleaseModel
            {
                Id = release.Id,
                Name = release.Name,
                Description = release.Description,
                From = release.From.Date,
                To = release.To.Date,
                State = release.State
            };

            return View("EditRelease", model);
        }