Esempio n. 1
0
        public void update(ref RequirementEntity entity, int RequirementRequestForChangesID, string rationale)
        {
            try
            {
                if (checkProjectBalance(entity.ProjectID, entity.cost))
                {
                    unit.BeginTransaction();

                    entity.versionNumber += 1;

                    if (entity.RequirementTemplateID.Equals(0))
                    {
                        entity.RequirementTemplateID = null;
                    }
                    if (entity.RequirementSubTypeID.Equals(0))
                    {
                        entity.RequirementSubTypeID = null;
                    }

                    Mapper.Initialize(cfg =>
                    {
                        cfg.CreateAutomaticMapping <RequirementEntity, RequirementVersionsEntity>();
                    });

                    RequirementRequestForChangesEntity request = requestService.get(RequirementRequestForChangesID);

                    request.RequestStatusID = 3;

                    RequirementVersionsEntity version = new RequirementVersionsEntity();
                    version = Mapper.Map <RequirementEntity, RequirementVersionsEntity>(entity);
                    version.creationDate = DateTime.Now;
                    version.rationale    = rationale;
                    version.RequirementRequestForChangesID = request.RequirementRequestForChangesID;
                    version.RequirementID = null;

                    versionService.add(ref version, false);
                    requestService.update(ref request, false);
                    update(ref entity, false);

                    unit.Commit();
                }
                else
                {
                    throw new ArgumentException("The inclusion of this requirement exceeds the project balance!");
                }
            }
            catch (Exception ex)
            {
                unit.Rollback();
                throw ex;
            }
        }
Esempio n. 2
0
        public ActionResult Edit(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                RequirementRequestForChangesEntity request = requestService.get(id);
                RequirementEditViewModel           vm      = Mapper.Map <RequirementEntity, RequirementEditViewModel>(request.StakeholderRequirement.Requirement);
                vm.RequirementRequestForChangesID = Convert.ToInt32(id);

                if (vm == null)
                {
                    return(HttpNotFound());
                }

                ViewData.Add("ImportanceID", new SelectList(measureService.getAll(), "ImportanceID", "description", vm.ImportanceID));
                ViewData.Add("RequirementStatusID", new SelectList(statusService.getAll(), "RequirementStatusID", "description", vm.RequirementStatusID));
                ViewData.Add("RequirementTypeID", new SelectList(typeService.getAll(), "RequirementTypeID", "description", vm.RequirementTypeID));
                ViewData.Add("CreationUserID", new SelectList(userService.getAll(), "UserID", "name", vm.CreationUserID));
                ViewData.Add("ProjectID", new SelectList(projectService.getAll(), "ProjectID", "DisplayName", vm.ProjectID));

                ViewData.Add("RequirementSubTypeID", new SelectList(subTypeService.getAll(), "RequirementSubTypeID", "description",
                                                                    vm.RequirementSubTypeID == null ? 0 : vm.RequirementSubTypeID));
                ViewData.Add("RequirementTemplateID", new SelectList(templateService.getAll(), "RequirementTemplateID", "description",
                                                                     vm.RequirementTemplateID == null ? 0 : vm.RequirementTemplateID));

                return(View(vm));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }