public ActionResult Create(string year)
        {
            var fsm = new FundingSourceModel();
            var model = new FundingSourceViewModel();
            model.FundingSource = fsm;
            model.TipYear = year;

            return View("Create", model);
        }
        public FundingSourceModel GetFundingSource(FundingSourceModel model)
        {
            SqlCommand cmd = new SqlCommand("[dbo].[GetFundingSource]");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FundingTypeId", model.FundingTypeId);
            cmd.Parameters.AddWithValue("@TimePeriodId", model.TimePeriodId);
            var dt = this.ExecuteDataTable(cmd);

            var dr = dt.Rows[0];

            model.FundingTypeId = (int)dr["FundingTypeID"];
            model.FundingType = dr["FundingType"].ToString();
            model.Code = dr["Code"].ToString();
            model.FundingGroup.Id = (int)dr["FundingGroupID"];
            model.FundingGroup.Name = dr["FundingGroup"].ToString();
            model.SourceOrganization.OrganizationId = (int)dr["SourceAgencyID"];
            model.SourceOrganization.OrganizationName = dr["SourceAgency"].ToString();
            model.RecipentOrganization.OrganizationId = (int)dr["RecipientAgencyID"];
            model.RecipentOrganization.OrganizationName = dr["RecipientAgency"].ToString();
            model.IsDiscretionary = dr["Discretion"].ToString().SmartParseDefault<bool>(default(bool));
            model.IsConformityImpact = dr["ConformityImpact"].ToString().SmartParseDefault<bool>(default(bool));
            model.IsLocal = dr["Local"].ToString().SmartParseDefault<bool>(default(bool));
            model.IsState = dr["State"].ToString().SmartParseDefault<bool>(default(bool));
            model.IsFederal = dr["Federal"].ToString().SmartParseDefault<bool>(default(bool));

            return model;
        }
 public void CreateFundingSource(FundingSourceModel model)
 {
     SqlCommand cmd = new SqlCommand("[dbo].[CreateFundingSource]");
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@FundingGroupId", model.FundingGroup.Id);
     cmd.Parameters.AddWithValue("@SourceAgencyId", model.SourceOrganization.OrganizationId);
     cmd.Parameters.AddWithValue("@RecipientAgencyId", model.RecipentOrganization.OrganizationId);
     cmd.Parameters.AddWithValue("@Descretion", model.IsDiscretionary);
     cmd.Parameters.AddWithValue("@ConformityImpact", model.IsConformityImpact);
     cmd.Parameters.AddWithValue("@ProgramId", model.ProgramId);
     cmd.Parameters.AddWithValue("@TimePeriodId", model.TimePeriodId);
     cmd.Parameters.AddWithValue("@FundingType", model.FundingType);
     cmd.Parameters.AddWithValue("@Code", model.Code);
     cmd.Parameters.AddWithValue("@IsState", model.IsState);
     cmd.Parameters.AddWithValue("@IsLocal", model.IsLocal);
     cmd.Parameters.AddWithValue("@IsFederal", model.IsFederal);
     this.ExecuteNonQuery(cmd);
 }
Example #4
0
        /// <summary>
        /// Gets the model for the TipFundingSource view
        /// </summary>
        /// <param name="tipYear"></param>
        /// <returns></returns>
        public IList<FundingSourceModel> GetTipFundingSources(string tipYear)
        {
            var model = new FundingSourceViewModel();
            SqlCommand cmd = new SqlCommand("[TIP].[GetFundingSources]");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@TIPYEAR", tipYear);
            var list = new List<FundingSourceModel>();
            using (IDataReader rdr = this.ExecuteReader(cmd))
            {
                while (rdr.Read())
                {
                    var fs= new FundingSourceModel();

                    fs.FundingTypeId = (int)rdr["FundingTypeId"];
                    fs.FundingType = rdr["FundingType"].ToString();
                    //fs.FundingLevel = rdr["FundingLevel"] != DBNull.Value ? rdr["FundingLevel"].ToString() : "NULL IN DB";
                    fs.Code= rdr["Code"].ToString();
                    fs.RecipentOrganization = new Organization() { OrganizationName = rdr["Recipient"].ToString() };
                    fs.SourceOrganization= new Organization() { OrganizationName = rdr["Source"].ToString() };
                    fs.TimePeriod = tipYear;
                    fs.Selector = "Not in DB";
                    fs.IsDiscretionary = (bool)rdr["Discretion"];

                    list.Add(fs);
                }

            }
            return list;
        }
Example #5
0
        /// <summary>
        /// Get a FundingSourceModel 
        /// </summary>
        /// <param name="tipYear"></param>
        /// <param name="fundingTypeId"></param>
        /// <returns></returns>
        public FundingSourceModel GetFundingSourceModel(string tipYear, int fundingTypeId)
        {
            var model = new FundingSourceModel();
            SqlCommand cmd = new SqlCommand("[TIP].[GetFundingSource]");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@TIPYEAR", tipYear);
            cmd.Parameters.AddWithValue("@FUNDINGTYPEID", fundingTypeId);
            using (IDataReader rdr = this.ExecuteReader(cmd))
            {
                if(rdr.Read())
                {
                    model.FundingTypeId = (int)rdr["FundingTypeId"];
                    model.FundingType = rdr["FundingType"] != DBNull.Value ? rdr["FundingType"].ToString() : "NULL IN DB";
                    model.Code = rdr["Code"] != DBNull.Value ? rdr["Code"].ToString() : "NULL IN DB";
                    model.RecipentOrganization = rdr["Recipient"] != DBNull.Value ? GetOrganization((int)rdr["Recipient"]) : null;
                    model.SourceOrganization = rdr["Source"] != DBNull.Value ? GetOrganization((int)rdr["Source"]) : null;
                    model.TimePeriod = rdr["TimePeriod"] != DBNull.Value ? rdr["TimePeriod"].ToString() : "NULL IN DB";
                    //model.FundingLevel = rdr["FundingLevel"] != DBNull.Value ? GetFundingLevel((int)rdr["FundingLevel"]) : null;
                    model.IsDiscretionary = (bool)rdr["Discretion"];
                    model.FundingGroup = rdr["FundingGroupId"] != DBNull.Value ? GetFundingGroup((int)rdr["FundingGroupId"]) : null;
                }
            }
            //Now load the resources

            model.Resources = GetFundingResources(tipYear, fundingTypeId);

            return model;
        }
Example #6
0
 public JsonResult GetFundingSource(FundingSourceModel model)
 {
     //FundingSourceModel model = new FundingSourceModel() { FundingTypeId = guid, TimePeriodId = timePeriodId };
     FundingSourceModel result;
     try
     {
         result = _tipRepository.GetFundingSource(model);
     }
     catch (Exception ex)
     {
         return Json(new
         {
             message = "Funding Source not found. An error has been logged."
             ,
             error = "true"
             ,
             exceptionMessage = ex.Message
         });
     }
     return Json(new
     {
         data = result
         ,
         message = "Funding successfully retrieved."
         ,
         error = "false"
     });
 }
Example #7
0
        public JsonResult CreateFundingSource(FundingSourceModel model)
        {
            model.ProgramId = (int)Enums.ApplicationState.TIP;
            model.TimePeriodId = _tipRepository.GetYearId(model.TimePeriod, Enums.TimePeriodType.TimePeriod);

            bool result = false;
            try
            {
                _tipRepository.CreateFundingSource(model);
            }
            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 = "Funding successfully created."
                ,
                error = "false"
            });
        }