Esempio n. 1
0
        public ActionResult Create(StoriesCreateModel model)
        {
            if (ModelState.IsValid)
            {
                using (var ctx = new Entities())
                {
                    model.Tag = Utils.Tagify(model.Summary);
                    int cellID = RouteData.Values["cell"].GetCellID();

                    if (ctx.TagExists(RequirementTypes.Story, cellID, null, model.Tag))
                    {
                        Warning("Já existe uma história com este nome!");
                    }
                    else
                    {
                        int userID = Authentication.GetLoggedUser().UserID;
                        int ret = ctx.SaveRequirement(RequirementTypes.Story, cellID, null, userID, model.Message, model.Tag, model.Summary, model.Text, null);

                        if (ret != 0)
                        {
                            Success("História inserida com sucesso!");
                            return RedirectToRoute("Details", new { @cell = RouteData.Values["cell"], @controller = RouteData.Values["controller"], @tag = model.Tag, @action = "Details" });
                        }
                        else
                        {
                            Error("Erro ao tentar inserir a nova história!");
                        }
                    }
                }
            }
            else
            {
                Warning("Preencha o formulário corretamente!");
            }
            return View(model);
        }
Esempio n. 2
0
        public ActionResult NewRequirement(RequirementCreateModel model)
        {
            if (ModelState.IsValid)
            {
                using (var ctx = new Entities())
                {
                    model.Tag = Utils.Tagify(model.Summary);
                    int cellID = RouteData.Values["cell"].GetCellID();

                    if (ctx.TagExists(RequirementTypes.Requirement, cellID, null, model.Tag))
                    {
                        Warning("Já existe um requisito com este nome!");
                    }
                    else
                    {
                        int userID = Authentication.GetLoggedUser().UserID;
                        int ret = ctx.SaveRequirement(RequirementTypes.Requirement, cellID, null, userID, model.Message, model.Tag, model.Summary, model.Text, model.StoryId);

                        if (ret != 0)
                        {
                            Success("Requisito inserido com sucesso!");
                            return RedirectToRoute("Details", new { @cell = RouteData.Values["cell"], @controller = "Requirements", @tag = model.Tag, @action = "Details" });
                        }
                        else
                        {
                            Error("Erro ao tentar inserir o novo requisito!");
                        }
                    }
                }
            }
            else
            {
                Warning("Preencha o formulário corretamente!");
            }

            NewRequirementModel edit = new NewRequirementModel(model);
            RouteData.Values["title"] = edit.Story.Summary;
            return View(edit);
        }
Esempio n. 3
0
        public ActionResult Publish(string tag)
        {
            using (var ctx = new Entities())
            {
                StoriesDetailsModel model = new StoriesDetailsModel(ctx.GetRequirementDetails(tag, null).FirstOrDefault());
                int cellID = RouteData.Values["cell"].GetCellID();

                int userID = Authentication.GetLoggedUser().UserID;
                int ret = ctx.SaveRequirement(RequirementTypes.Publish, cellID, model.RevisionId, userID, "Publicação de história", tag, model.Summary, model.Text, null);

                if (ret != 0)
                {
                    model = new StoriesDetailsModel(ctx.GetRequirementDetails(tag, null).FirstOrDefault());
                    RequirementRevision rev = ctx.RequirementRevisions.FirstOrDefault(i => i.RevisionID == model.RevisionId);
                    rev.Published = true;

                    if (ctx.SaveChanges() != 0)
                    {
                        Success("História publicada com sucesso!");
                        return RedirectToAction("Details", new { @tag = tag });
                    }
                }

                Error("Erro ao tentar publicar a história!");
                return RedirectToAction("Details", new { @tag = tag });
            }
        }
        public ActionResult MarkAsDone(string tag)
        {
            using (var ctx = new Entities())
            {
                RequirementsDetailsModel model = new RequirementsDetailsModel(ctx.GetRequirementDetails(tag, null).FirstOrDefault());
                int cellID = RouteData.Values["cell"].GetCellID();

                int userID = Authentication.GetLoggedUser().UserID;
                int ret = ctx.SaveRequirement(RequirementTypes.MarkAsDone, cellID, model.RevisionId, userID, "Requisito implementado", tag, model.Summary, model.Text, null);

                if (ret != 0)
                {
                    model = new RequirementsDetailsModel(ctx.GetRequirementDetails(tag, null).FirstOrDefault());
                    RequirementRevision rev = ctx.RequirementRevisions.FirstOrDefault(i => i.RevisionID == model.RevisionId);
                    rev.Published = true;

                    if (ctx.SaveChanges() != 0)
                    {
                        Success("Requisito finalizado com sucesso!");
                        return RedirectToAction("Details", new { @tag = tag });
                    }
                }

                Error("Erro ao tentar finalizar o requisito!");
                return RedirectToAction("Details", new { @tag = tag });
            }
        }