public Requirement(String desc, int priorityIn, RequirementCategory cat)
 {
     description = desc;
     priority    = priorityIn;
     tasks       = new List <Task>();
     this.cat    = cat;
 }
        public ActionResult Create(int id, RequirementCategory requirementCategory)
        {
            var project = _projectRepository.GetNullableById(id);

            if (project == null)
            {
                Message = string.Format(Messages.NotFound, "Project", id);
                return this.RedirectToAction<ProjectController>(a => a.Index());
            }

            // validate access
            var redirect = _accessValidator.CheckEditAccess(CurrentUser.Identity.Name, project);
            if (redirect != null)
            {
                Message = "Not authorized to edit project.";
                return redirect;
            }

            var existing = project.RequirementCategories.Where(a => a.Name == requirementCategory.Name).FirstOrDefault();

            if (existing != null)
            {
                if (existing.IsActive)
                {
                    ModelState.AddModelError("", "Requirement Cateogry already exists.");
                }
                else
                {
                    requirementCategory = existing;
                    requirementCategory.IsActive = true;
                }
            }
            else
            {
                requirementCategory.Project = project;

                ModelState.Clear();
                requirementCategory.TransferValidationMessagesTo(ModelState);
            }

            if (ModelState.IsValid)
            {
                _requirementCategoryRepository.EnsurePersistent(requirementCategory);

                Message = "RequirementCategory Created Successfully";

                return RedirectToAction("Index", new {id = id});
            }

            var viewModel = RequirementCategoryViewModel.Create(Repository, project);
            viewModel.RequirementCategory = requirementCategory;

            return View(viewModel);
        }
        public ActionResult Create(RequirementCategory requirementCategory)
        {
            if (ModelState.IsValid)
            {
                requirementCategory.CreatedByUserId = WebUser.Id;

                _requirementCategoryRepository.Create(requirementCategory);
                _unitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(requirementCategory));
        }
        public ActionResult Edit(RequirementCategory requirementCategory)
        {
            if (ModelState.IsValid)
            {
                var selectedRequirementCategory = _requirementCategoryRepository.Get(requirementCategory.Id);

                if (selectedRequirementCategory != null)
                {
                    selectedRequirementCategory.Title           = requirementCategory.Title;
                    selectedRequirementCategory.UpdatedByUserId = WebUser.Id;

                    _requirementCategoryRepository.Update(selectedRequirementCategory);
                    _unitOfWork.Commit();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(requirementCategory));
        }
Beispiel #5
0
        public static string AddNewCategory(string cateName)
        {
            RequirementCategory model = new RequirementCategory();

            int reVal = RequirementManageBLL.AddNewCategoryItem(cateName);

            if (reVal != 0)
            {
                model.ActiveStatus     = 1;
                model.CategoryName     = cateName;
                model.Id               = reVal;
                model.ParentCategoryId = 0;

                return(CommonLib.Helper.JsonSerializeObject(model));
            }
            else
            {
                return("");
            }
        }
Beispiel #6
0
        public IHttpActionResult Gettbl_Requirements(RequirementCategory category)
        {
            LogApi.Log(User.Identity.GetUserId(), "GetRequirement " + User.Identity.GetUserName());

            try
            {
                List <RequirementsModel> listRequirements = new List <RequirementsModel>();
                RequirementsModel        requirementModel;
                //var jobs = db.tbl_Jobs.Where(c => c.col_Category == category.Category);
                var requirments = db.tbl_Requirements;
                foreach (var r in requirments)
                {
                    var postedBy   = db.AspNetUsers.Where(m => m.Id == r.col_PostedBy).FirstOrDefault();
                    var postedById = db.AspNetUsers.Where(m => m.Id == r.col_PostedBy).FirstOrDefault();
                    requirementModel = new RequirementsModel();
                    requirementModel.col_RequirementCategory    = r.col_RequirementCategory;
                    requirementModel.col_RequirementEmail       = r.col_RequirementEmail;
                    requirementModel.col_RequirementContact     = r.col_RequirementContact;
                    requirementModel.col_RequirementDescription = r.col_RequirementDescription;
                    requirementModel.col_RequirementPostedDate  = r.col_RequirementPostedDate;
                    requirementModel.col_PostedById             = postedById.Id;
                    requirementModel.col_PostedBy = postedBy.FirstName + " " + postedBy.LastName + " " + postedBy.RollNo;
                    listRequirements.Add(requirementModel);
                }
                if (listRequirements.Count > 0)
                {
                    listRequirements = listRequirements.OrderByDescending(j => j.col_RequirementPostedDate).ToList();
                    return(Ok(listRequirements));
                }
                else
                {
                    return(Ok("No records found"));
                }
            }
            catch (Exception ex)
            {
                return(Ok(ex.Message));
            }
        }
Beispiel #7
0
        public ActionResult Update(RequirementCategory vm)
        {
            ApiResult <RequirementCategory> apiResult;

            if (ModelState.IsValid)
            {
                if (vm.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var category             = _requirementCategoryRepository.Get(vm.Id);
                        category.Title           = vm.Title;
                        category.UpdatedByUserId = WebUser.Id;
                        category.UpdatedOn       = DateTime.UtcNow;
                        _requirementCategoryRepository.Update(category);
                        _unitOfWork.Commit();
                        return(category);
                    }, "Requirement Category updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        vm.CreatedByUserId = WebUser.Id;
                        _requirementCategoryRepository.Create(vm);
                        _unitOfWork.Commit();
                        return(vm);
                    }, "Requirement Category created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <RequirementCategory>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Edit(int id, RequirementCategory requirementCategory)
        {
            var requirementCategoryToEdit = _requirementCategoryRepository.GetNullableById(id);

            if (requirementCategoryToEdit == null) return this.RedirectToAction<ProjectController>(a => a.Index());

            // validate access
            var redirect = _accessValidator.CheckEditAccess(CurrentUser.Identity.Name, requirementCategoryToEdit.Project);
            if (redirect != null)
            {
                Message = "Not authorized to edit project.";
                return redirect;
            }

            requirementCategoryToEdit.Name = requirementCategory.Name;

            ModelState.Clear();
            requirementCategoryToEdit.TransferValidationMessagesTo(ModelState);

            if (ModelState.IsValid)
            {
                _requirementCategoryRepository.EnsurePersistent(requirementCategoryToEdit);

                Message = "RequirementCategory Edited Successfully";

                return RedirectToAction("Index", requirementCategoryToEdit.Project.Id);
            }

            var viewModel = RequirementCategoryViewModel.Create(Repository, requirementCategoryToEdit.Project);
            viewModel.RequirementCategory = requirementCategory;

            return View(viewModel);
        }
        public ActionResult Delete(int id, RequirementCategory requirementCategory)
        {
            var requirementCategoryToDelete = _requirementCategoryRepository.GetNullableById(id);

            if (requirementCategoryToDelete == null) return this.RedirectToAction<ProjectController>(a => a.Index());

            // validate access
            var redirect = _accessValidator.CheckEditAccess(CurrentUser.Identity.Name, requirementCategoryToDelete.Project);
            if (redirect != null)
            {
                Message = "Not authorized to edit project.";
                return redirect;
            }

            requirementCategoryToDelete.IsActive = false;
            _requirementCategoryRepository.EnsurePersistent(requirementCategoryToDelete);

            Message = "RequirementCategory Removed Successfully";

            return this.RedirectToAction(a => a.Index(requirementCategoryToDelete.Project.Id));
        }