Esempio n. 1
0
        public void SaveDefaultSouceOfFundRecord(Guid TenantID, Guid OrganizationID)
        {
            DateTime dt           = DateTime.Now;
            var      Sourceoffund = db.SourceOfFunds.ToList();

            foreach (SourceOfFunds source in Sourceoffund)
            {
                db.SourceOfFundsOrganizationSettings.Add(new SourceOfFundsOrganizationSettings()
                {
                    SourceOfFundID     = source.SourceOfFundID,
                    OrganizationID     = OrganizationID,
                    TenantID           = TenantID,
                    EnableSourceOFFund = false,
                    DateCreated        = dt
                });
                db.SaveChanges();
            }

            var DefaultSourceOFFund1   = "Budgetary allocation/appropriation";
            var DefaultSourceOFFundID1 = db.SourceOfFunds.Where(x => x.SourceOfFund.Contains(DefaultSourceOFFund1)).Select(x => x.SourceOfFundID).FirstOrDefault();
            var sourceOfFund1          = db.SourceOfFundsOrganizationSettings.Where(x => x.SourceOfFundID == DefaultSourceOFFundID1 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();
            SourceOfFundsOrganizationSettings sourceOfFundsOrganizationSettings = sourceOfFund1.First();

            sourceOfFundsOrganizationSettings.EnableSourceOFFund = true;
            sourceOfFundsOrganizationSettings.DateModified       = dt;

            var DefaultSourceOFFund2   = "Internally generated fund";
            var DefaultSourceOFFundID2 = db.SourceOfFunds.Where(x => x.SourceOfFund.Contains(DefaultSourceOFFund2)).Select(x => x.SourceOfFundID).FirstOrDefault();
            var sourceOfFund2          = db.SourceOfFundsOrganizationSettings.Where(x => x.SourceOfFundID == DefaultSourceOFFundID2 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();

            sourceOfFundsOrganizationSettings = sourceOfFund2.First();
            sourceOfFundsOrganizationSettings.EnableSourceOFFund = true;
            sourceOfFundsOrganizationSettings.DateModified       = dt;

            var DefaultSourceOFFund3   = "Special intervention fund";
            var DefaultSourceOFFundID3 = db.SourceOfFunds.Where(x => x.SourceOfFund.Contains(DefaultSourceOFFund3)).Select(x => x.SourceOfFundID).FirstOrDefault();
            var sourceOfFund3          = db.SourceOfFundsOrganizationSettings.Where(x => x.SourceOfFundID == DefaultSourceOFFundID3 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();

            sourceOfFundsOrganizationSettings = sourceOfFund3.First();
            sourceOfFundsOrganizationSettings.EnableSourceOFFund = true;
            sourceOfFundsOrganizationSettings.DateModified       = dt;

            var DefaultSourceOFFund4   = "Power sector intervention fund";
            var DefaultSourceOFFundID4 = db.SourceOfFunds.Where(x => x.SourceOfFund.Contains(DefaultSourceOFFund4)).Select(x => x.SourceOfFundID).FirstOrDefault();
            var sourceOfFund4          = db.SourceOfFundsOrganizationSettings.Where(x => x.SourceOfFundID == DefaultSourceOFFundID4 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();

            sourceOfFundsOrganizationSettings = sourceOfFund4.First();
            sourceOfFundsOrganizationSettings.EnableSourceOFFund = true;
            sourceOfFundsOrganizationSettings.DateModified       = dt;

            var DefaultSourceOFFund5   = "ETF Special intervention fund";
            var DefaultSourceOFFundID5 = db.SourceOfFunds.Where(x => x.SourceOfFund.Contains(DefaultSourceOFFund5)).Select(x => x.SourceOfFundID).FirstOrDefault();
            var sourceOfFund5          = db.SourceOfFundsOrganizationSettings.Where(x => x.SourceOfFundID == DefaultSourceOFFundID5 && x.OrganizationID == OrganizationID && x.TenantID == TenantID).ToList();

            sourceOfFundsOrganizationSettings = sourceOfFund5.First();
            sourceOfFundsOrganizationSettings.EnableSourceOFFund = true;
            sourceOfFundsOrganizationSettings.DateModified       = dt;

            db.SaveChanges();
        }
Esempio n. 2
0
        public ActionResult Edit(SourceOfFundsOrganizationSettings sourceOfFundsOrganizationSettings, bool EnableSourceOFFund)
        {
            string email    = Request.Headers["Email"];
            var    tenantId = catalog.GetTenantIDFromClientURL(email);

            try
            {
                if (tenantId == null)
                {
                    return(Json(new
                    {
                        success = false,
                        message = "TenantId is null",
                        data = new { }
                    }, JsonRequestBehavior.AllowGet));
                }
                DateTime dt = DateTime.Now;
                var      CurrentSourceOfFundID = db.SourceOfFundsOrganizationSettings.FirstOrDefault(s => s.SourceOfFundID == sourceOfFundsOrganizationSettings.SourceOfFundID);

                if (CurrentSourceOfFundID == null)
                {
                    LogHelper.Log(Log.Event.UPDATE_SOURCEOFFUNDS, "SourceOfFundID not found");
                    return(Json(new
                    {
                        success = false,
                        message = "SourceOfFundID not found",
                        data = new { }
                    }, JsonRequestBehavior.AllowGet));
                }
                CurrentSourceOfFundID.EnableSourceOFFund = EnableSourceOFFund;
                CurrentSourceOfFundID.DateModified       = dt;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHelper.Log(Log.Event.UPDATE_SOURCEOFFUNDS, ex.Message);
                ExceptionError(ex.Message, ex.StackTrace);
            }
            return(Json(new
            {
                success = true,
                message = "Edited successfully",
                data = db.SourceOfFundsOrganizationSettings.Where(x => x.TenantID == tenantId).Select(x => new
                {
                    x.SourceOfFundID,
                    x.SourceOfFunds.SourceOfFund,
                    Enabled = x.EnableSourceOFFund
                })
            }, JsonRequestBehavior.AllowGet));
        }