Beispiel #1
0
        public ActionResult Delete(int id)
        {
            try
            {
                var actor = db.Actors.Find(id);
                db.Actors.Remove(actor);
                db.SaveChanges();
                NotificationSystem.SendNotification(EnumNotification.DELETE_ACTOR, "/Actor");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Edit(int id, string editActor)
        {
            try
            {
                var actor = db.Actors.Find(id);
                actor.Name            = editActor;
                db.Entry(actor).State = EntityState.Modified;
                db.SaveChanges();
                NotificationSystem.SendNotification(EnumNotification.EDIT_ACTOR, "/Actor");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult Create(string name)
        {
            int   projectID = (int)Session["projectID"];
            Actor actor     = new Actor();

            actor.Name       = name;
            actor.ID_Project = projectID;
            try
            {
                db.Actors.Add(actor);
                db.SaveChanges();
                NotificationSystem.SendNotification(EnumNotification.CREATE_ACTOR, "/Actor");
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Create(Requirement requirement)
        {
            int projectID = (int)Session["projectID"];

            requirement.ID_Project     = projectID;
            requirement.ID_Requirement = createID(projectID);

            if (db.Requirements.Where(r => r.ID_Project == projectID && r.ID_Requirement.Equals(requirement.ID_Requirement)).FirstOrDefault() != null)
            {
                ViewBag.Error = "Zadané ID požadavku se již v projektu vyskytuje. Zvolte prosím jiné.";
            }
            else
            {
                try
                {
                    db.Requirements.Add(requirement);
                    db.SaveChanges();

                    if (requirement.ID_ReqType == 1)
                    {
                        NotificationSystem.SendNotification(EnumNotification.CREATE_REQUIREMENT, "/Requirements/Functional");
                        return(RedirectToAction("Functional"));
                    }
                    else
                    {
                        NotificationSystem.SendNotification(EnumNotification.CREATE_REQUIREMENT, "/Requirements/Nonfunctional");
                        return(RedirectToAction("Nonfunctional"));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    ViewBag.Error = "Vyskytla se chyba. Opakujte prosím akci.";
                }
            }
            ViewBag.ID_ReqType  = new SelectList(db.ReqTypes, "ID", "Type");
            ViewBag.ID_Priority = db.PriorityRequirements.ToList();
            ViewBag.ID_Category = new SelectList(db.CategoryRequirements.Where(c => c.ID_Project == projectID), "ID", "Name");
            ViewBag.ID_Status   = db.StatusRequirements.ToList();

            return(View(requirement));
        }
Beispiel #5
0
        public ActionResult Delete(int id)
        {
            var file = db.Files.Find(id);

            try
            {
                if (System.IO.File.Exists(file.Path))
                {
                    System.IO.File.Delete(file.Path);
                    db.Files.Remove(file);
                    db.SaveChanges();
                    NotificationSystem.SendNotification(EnumNotification.DELETE_FILE, "/Storage");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(RedirectToAction("Index"));
        }
Beispiel #6
0
        public ActionResult Delete(int id)
        {
            var scenario = db.Scenarios.Find(id);

            try
            {
                db.ScenarioActors.RemoveRange(scenario.ScenarioActors);
                scenario.ScenarioActors.Clear();
                List <Scenario> alternativeScenarious = db.Scenarios.Where(s => s.ID_MainScenario == id).ToList();
                db.Scenarios.RemoveRange(alternativeScenarious);
                db.Scenarios.Remove(scenario);
                db.SaveChanges();
                NotificationSystem.SendNotification(EnumNotification.DELETE_SCENARIO, "/Scenario");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public ActionResult Delete(int id)
        {
            var useCase = db.UseCases.Find(id);

            try
            {
                db.Scenarios.RemoveRange(useCase.Scenarios);
                useCase.Scenarios.Clear();
                db.UseCaseActors.RemoveRange(useCase.UseCaseActors);
                useCase.UseCaseActors.Clear();
                db.UseCases.Remove(useCase);
                db.SaveChanges();
                NotificationSystem.SendNotification(EnumNotification.DELETE_USECASE, "/UseCase");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #8
0
        public ActionResult Create(Task task)
        {
            int userID    = (int)Session["userID"];
            int projectID = (int)Session["projectID"];

            task.ID_User_Creator = userID;
            task.ID_Project      = projectID;
            task.ID_State        = 1;

            try
            {
                db.Tasks.Add(task);
                db.SaveChanges();
                updateTaskHistory(projectID, 1, 0, true);
                NotificationSystem.SendNotification(EnumNotification.CREATE_TASK, "/Task");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(RedirectToAction("Index"));
        }
Beispiel #9
0
        public ActionResult Create(UseCase useCase, List <int> actors, List <int> requirements)
        {
            int projectID = (int)Session["projectID"];

            useCase.ID_Project = projectID;

            try
            {
                db.UseCases.Add(useCase);
                db.SaveChanges();
                Session["actors"]       = actors;
                Session["requirements"] = requirements;
                NotificationSystem.SendNotification(EnumNotification.CREATE_USECASE, "/UseCase");
                return(RedirectToAction("AddActors"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            ViewBag.actors       = new MultiSelectList(db.Actors.Where(a => a.ID_Project == projectID), "ID", "Name");
            ViewBag.requirements = new MultiSelectList((from s in db.Requirements.Where(c => c.ID_Project == projectID && c.ID_ReqType == 1) select new { s.ID, FullReq = s.ID_Requirement + " " + s.Text }), "ID", "FullReq");
            ViewBag.category     = new SelectList(db.CategoryRequirements.Where(c => c.ID_Project == projectID).OrderBy(o => o.Name), "ID", "Name");
            return(View(useCase));
        }
        public ActionResult Edit(Requirement requirement)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var old = db.Requirements.Find(requirement.ID);
                    old.ID_ReqType      = requirement.ID_ReqType;
                    old.Text            = requirement.Text;
                    old.ID_Requirement  = requirement.ID_Requirement;
                    old.ID_Category     = requirement.ID_Category;
                    old.ID_Priority     = requirement.ID_Priority;
                    old.ID_Status       = requirement.ID_Status;
                    old.Source          = requirement.Source;
                    db.Entry(old).State = EntityState.Modified;
                    db.SaveChanges();

                    LinkedList <CategoryRequirement> categories = new LinkedList <CategoryRequirement>(db.CategoryRequirements.Where(c => c.ID_Project == old.ID_Project).ToList());
                    categories.AddFirst(new CategoryRequirement()
                    {
                        ID = 0, Name = "Kategorie"
                    });
                    ViewBag.ID_Category = new SelectList(categories, "ID", "Name");

                    LinkedList <PriorityRequirement> priorities = new LinkedList <PriorityRequirement>(db.PriorityRequirements.ToList());
                    priorities.AddFirst(new PriorityRequirement()
                    {
                        ID = 0, Priority = "Priorita"
                    });
                    ViewBag.ID_Priority = new SelectList(priorities, "ID", "Priority");

                    LinkedList <StatusRequirement> statuses = new LinkedList <StatusRequirement>(db.StatusRequirements.ToList());
                    statuses.AddFirst(new StatusRequirement()
                    {
                        ID = 0, Status = "Status"
                    });
                    ViewBag.ID_Status = new SelectList(statuses, "ID", "Status");

                    if (requirement.ID_ReqType == 1)
                    {
                        NotificationSystem.SendNotification(EnumNotification.EDIT_REQUIREMENT, "/Requirements/Functional");
                        return(RedirectToAction("Functional"));
                    }
                    else
                    {
                        NotificationSystem.SendNotification(EnumNotification.EDIT_REQUIREMENT, "/Requirements/Nonfunctional");
                        return(RedirectToAction("Nonfunctional"));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    ViewBag.Error       = "Vyskytla se chyba. Opakujte prosím akci.";
                    ViewBag.ID_Priority = db.PriorityRequirements.ToList();
                    ViewBag.ID_Category = new SelectList(db.CategoryRequirements.Where(c => c.ID_Project == requirement.ID_Project), "ID", "Name", requirement.ID_Requirement);
                    ViewBag.ID_Status   = db.StatusRequirements.ToList();
                    ViewBag.ID_ReqType  = new SelectList(db.ReqTypes, "ID", "Type", requirement.ID_ReqType);
                }
            }

            return(View(requirement));
        }