protected ProjectAmendments UpdateStatus(ProjectAmendments amendment)
 {
     amendment.AmendmentStatusId = (Int32)Enums.TIPAmendmentStatus.Submitted;
     //amendment.AmendmentTypeId = (Int32)Enums.AmendmentType.Administrative;
     amendment.VersionStatusId = (Int32)Enums.TIPVersionStatus.Pending;
     return amendment;
 }
 public ProjectAmendments UpdateStatus(ProjectAmendments amendment)
 {
     amendment.AmendmentStatusId = (Int32)Enums.TIPAmendmentStatus.Amended;
     //amendment.AmendmentTypeId = (Int32)Enums.AmendmentType.Administrative;
     amendment.VersionStatusId = (Int32)Enums.TIPVersionStatus.Active;
     return amendment;
 }
        public static IAmendmentStrategy PickStrategy(IProjectRepository repo, ProjectAmendments amendment)
        {
            IAmendmentStrategy strategy = null;

            switch (amendment.AmendmentStatusId)
            {
                case 10734: // Amended
                case (Int32)Enums.TIPAmendmentStatus.Amended:
                case (Int32)Enums.TIPAmendmentStatus.Adopted:
                    strategy = new AmendedToSubmitted(repo, amendment);
                    break;
                case 10736: // Approved
                case 1769:
                    strategy = new ApprovalToSubmitted(repo, amendment);
                    break;
                case 10740: // Proposed
                case 1767:
                    strategy = new ProposedToAmended(repo, amendment);
                    break;
                case 10742: // Submitted
                case 1770:
                    strategy = new SubmittedToProposed(repo, amendment);
                    break;

                default:
                    Logger.Warn("Unknown TIP Amendment status " + amendment.AmendmentStatusId);
                    break;
            }
            return strategy;
        }
 protected ProjectAmendments UpdateStatus(ProjectAmendments amendment)
 {
     //set the Amendment Reason to "Deleting previous amendment"
     amendment.AmendmentStatusId = (Int32)Enums.TIPAmendmentStatus.Submitted;
     amendment.AmendmentTypeId = (Int32)Enums.AmendmentType.Administrative;
     amendment.AmendmentReason = "Deleting previous amendment";
     amendment.AmendmentCharacter = "";
     amendment.VersionStatusId = (Int32)Enums.TIPVersionStatus.Pending;
     return amendment;
 }
 // Move an amendment along in its life cycle.
 // This used to be Amend in the ProjectController.
 // POST api/tipprojectamendment
 public int Post(ProjectAmendments amendment)
 {
     try
     {
         amendment.LocationMapPath = Trips4.Configuration.DRCOGConfig.GetConfig().LocationMapPath;
         IAmendmentStrategy strategy = AmendmentStrategy.PickStrategy(ProjectRepository, amendment);
         if (strategy == null)
         {
             throw new Exception("Cannot process this amendment status");
         }
         int projectVersionId = strategy.Amend();
         return projectVersionId;
     }
     catch (Exception ex)
     {
         Logger.WarnException("Could not Post TIP Project Amendment", ex);
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message });
     }
 }
        // If the amendment is in progress, just delete it.
        // If the amendment was approved, create another amendment for the deletion.
        // DELETE api/tipprojectamendment/5
        public int Delete(int id)
        {
            try
            {
                ProjectAmendments amendment = new ProjectAmendments()
                {
                    LocationMapPath = Trips4.Configuration.DRCOGConfig.GetConfig().LocationMapPath,
                    ProjectVersionId = id
                };

                IDeleteStrategy strategy = new DeleteStrategy(this.ProjectRepository, amendment).PickStrategy();
                int returnId = strategy.Delete();
                return returnId;
            }
            catch (Exception ex)
            {
                Logger.WarnException("Could not Delete TIP Project Amendment", ex);
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message });
            }
        }
示例#7
0
 protected int Copy(string tipYear, ProjectAmendments amendment)
 {
     if (amendment.AmendmentStatusId == (Int32)Enums.TIPAmendmentStatus.Proposed)
     {
         amendment.ProjectVersionId = _projectVersionID;
         amendment.PreviousProjectVersionId = (Int32)amendment.ProjectVersionId;
         amendment.ProjectVersionId = _repo.CopyProject(amendment.PreviousProjectVersionId);
         amendment.AmendmentReason = String.Empty;
         amendment.AmendmentCharacter = "Proposed for adoption into " + tipYear;
     }
     else
     {
         amendment.ProjectVersionId = _repo.RestoreProjectVersion(_projectVersionID, tipYear);
         _repo.RestoreProjectVersionFinancials(_projectVersionID, (int)amendment.ProjectVersionId, tipYear);
         amendment.AmendmentReason = String.Empty;
         amendment.AmendmentCharacter = "Imported from " + tipYear;
         //amendment.ProjectVersionId = newProjectVersionID;
     }
     _repo.UpdateProjectAmendmentStatus(amendment);
     _repo.UpdateAmendmentDetails(amendment);
     return (int)amendment.ProjectVersionId;
 }
 public InProgressDelete(ProjectAmendments amendment, IProjectRepository repo)
 {
     _repo = repo;
     _amendment = amendment;
 }
 protected ProjectAmendments UpdateStatus(ProjectAmendments amendment)
 {
     amendment.AmendmentStatusId = (Int32)Enums.TIPAmendmentStatus.Proposed;
     amendment.VersionStatusId = (Int32)Enums.TIPVersionStatus.Pending;
     return amendment;
 }
 public SubmittedToProposed(IProjectRepository repo, ProjectAmendments amendment)
 {
     ProjectRepository = repo;
     Amendment = UpdateStatus(amendment);
 }
 // Update an Amendment, with the ID of ProjectVersionId.
 // if AmendmentStatusId is 0, only Reason and Character are updated by the sproc.
 // PUT api/tipprojectamendment
 public void Put(ProjectAmendments value)
 {
     try
     {
         if (value.AmendmentStatusId != 0)
         {
             ProjectRepository.UpdateProjectAmendmentStatus(value);
         }
         else
         {
             ProjectRepository.UpdateAmendmentDetails(value);
         }
     }
     catch (Exception ex)
     {
         Logger.WarnException("Could not Put TIP Project Amendment", ex);
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message });
     }
 }
示例#12
0
 public DeleteStrategy(IProjectRepository repo, ProjectAmendments amendment)
 {
     _repo = repo;
     _amendment = amendment;
 }
示例#13
0
        /// <summary>
        /// Update a project's Amendment Status
        /// </summary>
        /// <param name="model"></param>
        public void UpdateProjectAmendmentStatus(ProjectAmendments model)
        {
            //throw new NotImplementedException();
            using (SqlCommand command = new SqlCommand("[TIP].[UpdateProjectAmendmentStatus]") { CommandType = CommandType.StoredProcedure })
            {
                command.Parameters.AddWithValue("@ProjectVersionId", model.ProjectVersionId);
                command.Parameters.AddWithValue("@AmendmentStatusId", model.AmendmentStatusId);
                command.Parameters.AddWithValue("@AmendmentTypeId", model.AmendmentTypeId);
                command.Parameters.AddWithValue("@VersionStatusId", model.VersionStatusId);
                command.Parameters.AddWithValue("@AmendmentReason", String.IsNullOrEmpty(model.AmendmentReason) ? null : model.AmendmentReason);
                command.Parameters.AddWithValue("@AmendmentCharacter", String.IsNullOrEmpty(model.AmendmentCharacter) ? null : model.AmendmentCharacter);
                this.ExecuteNonQuery(command);
            }

            if (model.UpdateLocationMap)
            {
                string fileName = String.Empty;
                string newName = String.Empty;

                using (SqlCommand command = new SqlCommand("[TIP].[UpdateProjectVersionLocationMap]") { CommandType = CommandType.StoredProcedure })
                {
                    command.Parameters.AddWithValue("@ProjectVersionId", model.ProjectVersionId);

                    using (IDataReader rdr = ExecuteReader(command))
                    {
                        if (rdr.Read())
                        {
                            fileName = rdr["fileName"].ToString();
                            newName = rdr["newName"].ToString();
                        }
                    }
                }
                try
                {
                    if (!fileName.Equals(String.Empty) && !newName.Equals(String.Empty))
                    {
                        FileHandler.Copy(fileName, newName, model.LocationMapPath, model.LocationMapPath);
                    }
                }
                catch
                {

                }
            }
        }
 public ApprovalToSubmitted(IProjectRepository repo, ProjectAmendments amendment)
 {
     ProjectRepository = repo;
     Amendment = UpdateStatus(amendment);
 }
示例#15
0
 public void UpdateAmendmentDetails(ProjectAmendments amendment)
 {
     using (SqlCommand command = new SqlCommand("TIP.UpdateAmendmentDetails") { CommandType = CommandType.StoredProcedure })
     {
         command.Parameters.AddWithValue("@ProjectVersionID", amendment.ProjectVersionId);
         command.Parameters.AddWithValue("@AmendmentReason", amendment.AmendmentReason);
         command.Parameters.AddWithValue("@AmendmentCharacter", amendment.AmendmentCharacter);
         this.ExecuteNonQuery(command);
     }
 }
示例#16
0
        public ActionResult DeleteAmendment(Int32 projectVersionId, Int32 previousProjectVersionId, string year)
        {
            ProjectAmendments amendment = new ProjectAmendments()
            {
                LocationMapPath = _config.LocationMapPath,
                ProjectVersionId = projectVersionId
            };

            IDeleteStrategy strategy = new DeleteStrategy(this._projectRepository, amendment).PickStrategy();
            int returnId = strategy.Delete();
            previousProjectVersionId = returnId != 0 ? returnId : previousProjectVersionId;

            if (!previousProjectVersionId.Equals(default(int)))
            {
                return RedirectToAction("Details", new { controller = "Project", id = previousProjectVersionId, message = "Amendment deleted successfully." });
            }
            else
                return RedirectToAction("ProjectList", new { controller = "Tip", tipYear = year });
        }
示例#17
0
 public ActionResult Amend(int projectVersionId, int previousVersionId)
 {
     ProjectAmendments amendment = new ProjectAmendments()
     {
         ProjectVersionId = projectVersionId
         ,
         PreviousProjectVersionId = previousVersionId
     };
     int result = Amend(amendment);
     //amendment.LocationMapPath = DRCOGConfig.GetConfig().LocationMapPath;
     //IAmendmentStrategy strategy = new AmendmentStrategy(_projectRepository, amendment).PickStrategy();
     //int projectVersionId = strategy.Amend();
     return RedirectToAction("Funding", new { controller = "Project", id = result, message = "Amendment processed successfully." });
 }
示例#18
0
 private int Amend(ProjectAmendments amendment)
 {
     amendment.LocationMapPath = DRCOGConfig.GetConfig().LocationMapPath;
     IAmendmentStrategy strategy = new AmendmentStrategy(_projectRepository, amendment).PickStrategy();
     int projectVersionId = strategy.Amend();
     return projectVersionId;
 }
示例#19
0
 public JsonResult UpdateAmendmentDetails(ProjectAmendments amendment)
 {
     try
     {
         _projectRepository.UpdateAmendmentDetails(amendment);
     }
     catch (Exception ex)
     {
         return Json(new
         {
             message = "Changes could not be stored. An error has been logged."
             ,
             error = "true"
             ,
             exceptionMessage = ex.Message
         });
     }
     return Json(new
     {
         message = "Amendment Detail updated successfully."
         ,
         error = "false"
     });
 }
示例#20
0
        /// <summary>
        /// Deletes a ProjectVersion
        /// </summary>
        /// <param name="projectVersionId"></param>
        /// <returns>LocationMap Filename</returns>
        public String DeleteProjectVersion(ProjectAmendments model)
        {
            SqlCommand cmd = new SqlCommand("[TIP].[DeleteProjectVersion]");
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@ProjectVersionID", model.ProjectVersionId);
            SqlParameter outParam = new SqlParameter("@fileName", SqlDbType.VarChar,100);
            outParam.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(outParam);
            SqlConnection con = new SqlConnection(this.ConnectionString);
            cmd.Connection = con;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

            string fileName = cmd.Parameters["@fileName"].Value != DBNull.Value ? cmd.Parameters["@fileName"].Value.ToString() : String.Empty;
            //string fileName = (String)cmd.Parameters["@fileName"].Value.ToString();
            try
            {
                if (!fileName.Equals(String.Empty))
                {
                    FileHandler.Delete(fileName, model.LocationMapPath);
                }
                else
                {
                    //throw new NoNullAllowedException();
                }
            }
            catch
            {

            }

            return String.Empty; //(String)cmd.Parameters["@fileName"].Value;
        }
示例#21
0
        public JsonResult Amend(int projectVersionId)
        {
            int result = default(int);

            TipSummary summary = _projectRepository.GetProjectSummary(projectVersionId);

            ProjectAmendments amendment = new ProjectAmendments()
            {
                ProjectVersionId = projectVersionId
                ,
                PreviousProjectVersionId = summary.PreviousVersionId
            };
            try
            {
                amendment.LocationMapPath = DRCOGConfig.GetConfig().LocationMapPath;
                IAmendmentStrategy strategy = new AmendmentStrategy(_projectRepository, amendment).PickStrategy();
                result = strategy.Amend();
            }
            catch (Exception ex)
            {
                return Json(new
                {
                    message = "Changes could not be stored. An error has been logged."
                    ,
                    error = "true"
                    ,
                    exceptionMessage = ex.Message
                });
            }
            return Json(new
            {
                data = result
                ,
                message = "Project successfully amended."
                ,
                error = "false"
            });
        }
示例#22
0
 public ApprovedDelete(ProjectAmendments amendment, IProjectRepository repo)
 {
     Amendment = amendment;
     ProjectRepository = repo;
 }
示例#23
0
 /*
     *Get Current Amendment Status
      * Does project need to be copied?
      * Amend Project
      * Check if Previous Active Amendment needs to be changed to inactive
      * Return to details page
 */
 protected AmendmentStrategy(IProjectRepository repo, ProjectAmendments amendment)
 {
     ProjectRepository = repo;
     Amendment = amendment;
 }