public async Task <IActionResult> CreateLiabilities(int id, [Bind("LenderName,Balance,Payment,IsConsolidated,LiabilityTypeId")] Liability liability) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var customer = _context.Customers.Where(c => c.IdentityUserId == userId).FirstOrDefault(); var applicationInDb = _context.Applications.Where(c => c.Id == id).SingleOrDefault(); var loanProfiles = _context.LoanProfiles.Where(a => a.ApplicationId == id).ToList(); liability.ApplicationId = id; _context.Add(liability); _context.SaveChanges(); Liabilities_LoanProfiles liabilitiesLoanProfiles = new Liabilities_LoanProfiles(); foreach (var item in loanProfiles) { liabilitiesLoanProfiles.LoanProfileId = item.Id; liabilitiesLoanProfiles.LiabilityId = liability.Id; _context.Liabilities_LoanProfiles.Add(liabilitiesLoanProfiles); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(CreateLiabilities))); }
public ActionResult Fine(int TableId, int EquipmentId, int ClassId, string Barcode) { Liability a = new Liability(); a.Equipment = (from y in con.Equipments where y.EquipmentId == EquipmentId select y.Make).FirstOrDefault(); a.StudenInfotId = (from y in con.Tables where y.TableId == TableId select y.StudentId).FirstOrDefault(); a.Fine = "To be Determined"; a.Status = "Unsettled"; a.Barcode = Barcode; a.LaboratoryId = (from y in con.Classes where y.ClassId == ClassId select y.LabId).FirstOrDefault(); con.AddToLiabilities(a); Dispense b = new Dispense(); var x = (from y in con.Dispenses where y.EquipmentId == EquipmentId && y.TableId == TableId && y.ClassId == ClassId select y).FirstOrDefault(); x.Status = "liability"; con.SaveChanges(); return(RedirectToAction("ViewEquipment", "Staff", new { TableId = TableId, ClassId = ClassId })); }
private async Task AddToContextAsync(Liability entity, CancellationToken cancellationToken, LiabilityType liability) { switch (liability) { case LiabilityType.MOT: await context.MOTs.AddAsync(entity as MOT, cancellationToken); return; case LiabilityType.CivilLiability: await context.CivilLiabilities.AddAsync(entity as CivilLiability, cancellationToken); return; case LiabilityType.CarInsurance: await context.CarInsurances.AddAsync(entity as CarInsurance, cancellationToken); return; case LiabilityType.Vignette: await context.Vignettes.AddAsync(entity as Vignette, cancellationToken); return; default: throw new InvalidLiabilityTypeException($"Invalid liability type: {liability}");; } }
public Dictionary <DateTime, double> GetFutureNetWorthByMonth(DateTime currentDate, DateTime futureDate) { Dictionary <DateTime, double> netWorthDict = new Dictionary <DateTime, double>(); List <DateTime> dates = DateCalculations.GetAllMonthsBetweenTwoDates(currentDate, futureDate); Asset[] assetsClone = new Asset[Assets.Count]; Assets.CopyTo(assetsClone, 0); Liability[] liabilitiesClone = new Liability[Liabilities.Count]; Liabilities.CopyTo(liabilitiesClone, 0); for (int i = 0; i < dates.Count; i++) { double futureNetWorth = 0; foreach (Asset a in assetsClone) { futureNetWorth += (a.CurrentValue += Math.Abs(a.CurrentValue) * ((a.InterestRate / 12.0) / 100.0)); } foreach (Liability l in liabilitiesClone) { futureNetWorth -= (l.CurrentValue += Math.Abs(l.CurrentValue) * ((l.InterestRate / 12.0) / 100.0)); } netWorthDict.Add(dates[i], futureNetWorth); } return(netWorthDict); }
/// <summary> /// Fill method for populating an entire collection of Liabilities /// </summary> public virtual void Fill(Liabilities liabilities) { // create the connection to use SqlConnection cnn = new SqlConnection(Liability.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectLiabilities"); // Send the collection and data to the object factory CreateObjectsFromData(liabilities, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(Liabilities liabilities, System.Data.DataSet data) { // Do nothing if we have nothing if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0) { return; } // Create a local variable for the new instance. Liability newobj = null; // Create a local variable for the data row instance. System.Data.DataRow dr = null; // Iterate through the table rows for (int i = 0; i < data.Tables[0].Rows.Count; i++) { // Get a reference to the data row dr = data.Tables[0].Rows[i]; // Create a new object instance newobj = System.Activator.CreateInstance(liabilities.ContainsType[0]) as Liability; // Let the instance set its own members newobj.SetMembers(ref dr); // Add the new object to the collection instance liabilities.Add(newobj); } }
public IActionResult CreateLiabilities(int id) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var customer = _context.Customers.Where(c => c.IdentityUserId == userId).FirstOrDefault(); ContactCustomerViewModel viewModel = new ContactCustomerViewModel(); var applicationInDb = _context.Applications.Where(c => c.Id == id).SingleOrDefault(); var liabilities = _context.Liabilities.Where(l => l.ApplicationId == id).ToList(); viewModel.Liabilities = liabilities; if (!liabilities.Any()) { applicationInDb.Liabilities = null; } Liability newLiability = new Liability(); viewModel.Application = applicationInDb; viewModel.Liability = newLiability; viewModel.Customer = customer; ViewData["LiabilityTypes"] = new SelectList(_context.LiabilityTypes, "Id", "Name"); return(View(viewModel)); }
public ActionResult Liability(itmmLiability a) { StudentInfo c = new StudentInfo(); c.FirstName = "autogen"; c.FamiliyName = "autogen"; c.StudentId = a.IdNumber.ToString(); c.CourseAndYear = "autogen"; con.AddToStudentInfoes(c); var labid = getLabId(); Liability b = new Liability(); b.StudenInfotId = Convert.ToInt32(a.IdNumber); b.Equipment = a.Equipment; b.Fine = a.Fine; b.Status = a.Status; b.LaboratoryId = labid; b.StudenInfotId = c.StudentInfoId; con.AddToLiabilities(b); con.SaveChanges(); return(RedirectToAction("Liability")); }
public ActionResult <decimal> GetTotalLiabilities(Liability liability) { var liabilityTotals = liability.CreditCard1 + liability.CreditCard2 + liability.OtherCredit + liability.Mortgage1 + liability.Mortgage2 + liability.LineOfCredit + liability.InvestmentLoan + liability.StudentLoan + liability.CarLoan; return(Ok(liabilityTotals)); }
public async Task <IActionResult> EditLiabilities(int id, [Bind("LenderName,Balance,Payment")] Liability liability) { var applicationInDb = _context.Applications.Where(c => c.Id == id).SingleOrDefault(); //indexCustomer // _context.Update(application); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <ActionResult <int> > PostLiability([FromBody] Liability liability) { _context.Liabilities.Add(liability); try { await _context.SaveChangesAsync(); } catch { return(BadRequest("Unexpected conflict encountered while saving liability")); } return(Ok(liability.Identifier)); }
/// <summary> /// Deletes the object. /// </summary> public virtual void Delete(Liability deleteObject) { // create a new instance of the connection SqlConnection cnn = new SqlConnection(Liability.GetConnectionString()); // create local variable array for the sql parameters SqlParameterHash sqlparams = null; try { // discover the parameters sqlparams = SqlHelperParameterCache.GetSpParameterSet(Liability.GetConnectionString(), "gsp_DeleteLiability"); // Store the parameter for the Id attribute. sqlparams["@id"].Value = deleteObject.Id; using (cnn) { // open the connection cnn.Open(); // Execute the stored proc to perform the delete on the instance. SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_DeleteLiability", sqlparams); // close the connection after usage cnn.Close(); } // nullify the connection var cnn = null; } catch (SqlException sqlex) { throw sqlex; } // nullify the reference deleteObject = null; }
/// <summary> /// Fill method for populating a collection by LiabilityType /// </summary> public void FillByLiabilityType(Liabilities liabilities, System.Int16 id) { // create the connection to use SqlConnection cnn = new SqlConnection(Liability.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Liability.GetConnectionString(), "gsp_SelectLiabilitiesByLiabilityType"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@type"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectLiabilitiesByLiabilityType", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(liabilities, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// Fills a single instance with data based on its primary key values. /// </summary> public virtual void Fill(Liability liability, System.Int64 id) { // create the connection to use SqlConnection cnn = new SqlConnection(Liability.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(Liability.GetConnectionString(), "gsp_SelectLiability"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@id"].Value = id; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectLiability", sqlparams); if (datareader.Read()) { liability.SetMembers(ref datareader); } cnn.Close(); // close the connection } // nullify the connection var cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
public async Task <IActionResult> PutLiability([FromBody] Liability liability) { _context.Liabilities.Update(liability); try { await _context.SaveChangesAsync(); return(Ok()); } catch (DbUpdateConcurrencyException) { return(NotFound("Cannot find liability with that id to update")); } catch { return(BadRequest("Unexpected error while updating liability")); } }
public ActionResult Liability(itmmLiability a) { StudentInfo c = new StudentInfo(); c.FirstName = "autogen"; c.FamiliyName = "autogen"; c.StudentId = a.IdNumber.ToString(); c.CourseAndYear = "autogen"; con.AddToStudentInfoes(c); var labid = getLabId(); Liability b = new Liability(); b.StudenInfotId = a.IdNumber;//Convert.ToInt32(a.IdNumber); // b.Equipment = a.Equipment; b.Equipment = (from y in con.Equipments where y.Barcode == a.Barcode select y.Make).FirstOrDefault(); b.Fine = a.Fine; b.Status = a.Status; b.LaboratoryId = labid; b.Barcode = a.Barcode; // b.StudenInfotId = c.StudentInfoId; con.AddToLiabilities(b); var d = (from y in con.Equipments where y.Barcode == a.Barcode select y).FirstOrDefault(); d.Status = "Liability"; con.SaveChanges(); return(RedirectToAction("Liability")); }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(Liabilities liabilities, System.Data.SqlClient.SqlDataReader data) { // Do nothing if we have nothing if (data == null) { return; } // Create a local variable for the new instance. Liability newobj = null; // Iterate through the data reader while (data.Read()) { // Create a new object instance newobj = System.Activator.CreateInstance(liabilities.ContainsType[0]) as Liability; // Let the instance set its own members newobj.SetMembers(ref data); // Add the new object to the collection instance liabilities.Add(newobj); } }
public async Task <long> Handle(CreateFactorCommand request, CancellationToken cancellationToken) { NWFactor entity; if (request.IsAsset) { entity = new Asset { Id = request.Id, Name = request.Name, CurrentValue = request.CurrentValue, HasInterest = request.HasInterest, InterestRate = request.InterestRate, Type = request.Type, UserID = request.UserID }; _context.Assets.Add((Asset)entity); } else { entity = new Liability { Id = request.Id, Name = request.Name, CurrentValue = request.CurrentValue, HasInterest = request.HasInterest, InterestRate = request.InterestRate, Type = request.Type, UserID = request.UserID }; _context.Liabilities.Add((Liability)entity); } await _context.SaveChangesAsync(cancellationToken); return(entity.Id); }
private void RemoveFromContext(Liability entity, LiabilityType liability) { switch (liability) { case LiabilityType.MOT: context.MOTs.Remove(entity as MOT); return; case LiabilityType.CivilLiability: context.CivilLiabilities.Remove(entity as CivilLiability); return; case LiabilityType.CarInsurance: context.CarInsurances.Remove(entity as CarInsurance); return; case LiabilityType.Vignette: context.Vignettes.Remove(entity as Vignette); return; default: throw new InvalidLiabilityTypeException($"Invalid liability type: {liability}"); } }
/// <summary> /// Persists the object. /// </summary> public virtual void Persist(Liability persistObject, SqlTransaction sqlTrans) { // create local variable array for the sql parameters SqlParameterHash sqlparams = null; // Create a local variable for the connection SqlConnection cnn = null; // Use the parameter overload or create a new instance if (sqlTrans == null) { cnn = new SqlConnection(Liability.GetConnectionString()); } try { // discover the parameters if (persistObject.Persisted) { sqlparams = SqlHelperParameterCache.GetSpParameterSet(Liability.GetConnectionString(), "gsp_UpdateLiability"); } else { sqlparams = SqlHelperParameterCache.GetSpParameterSet(Liability.GetConnectionString(), "gsp_CreateLiability"); } // Store the parameter for the LoanApplicationId attribute. sqlparams["@loanApplicationId"].Value = persistObject.LoanApplicationId; // Store the parameter for the BorrowerId attribute. sqlparams["@borrowerId"].Value = persistObject.BorrowerId; // Store the parameter for the REO_ID attribute. if (!persistObject.REO_IDIsNull) { sqlparams["@rEO_ID"].Value = persistObject.REO_ID; } // Store the parameter for the HolderStreetAddress attribute. if (!persistObject.HolderStreetAddressIsNull) { sqlparams["@holderStreetAddress"].Value = persistObject.HolderStreetAddress; } // Store the parameter for the HolderCity attribute. if (!persistObject.HolderCityIsNull) { sqlparams["@holderCity"].Value = persistObject.HolderCity; } // Store the parameter for the HolderState attribute. if (!persistObject.HolderStateIsNull) { sqlparams["@holderState"].Value = persistObject.HolderState; } // Store the parameter for the HolderPostalCode attribute. if (!persistObject.HolderPostalCodeIsNull) { sqlparams["@holderPostalCode"].Value = persistObject.HolderPostalCode; } // Store the parameter for the AlimonyOwedToName attribute. if (!persistObject.AlimonyOwedToNameIsNull) { sqlparams["@alimonyOwedToName"].Value = persistObject.AlimonyOwedToName; } // Store the parameter for the AccountIdentifier attribute. if (!persistObject.AccountIdentifierIsNull) { sqlparams["@accountIdentifier"].Value = persistObject.AccountIdentifier; } // Store the parameter for the ExclusionIndicator attribute. sqlparams["@exclusionIndicator"].Value = persistObject.ExclusionIndicator; // Store the parameter for the HolderName attribute. if (!persistObject.HolderNameIsNull) { sqlparams["@holderName"].Value = persistObject.HolderName; } // Store the parameter for the MonthlyPaymentAmount attribute. if (!persistObject.MonthlyPaymentAmountIsNull) { sqlparams["@monthlyPaymentAmount"].Value = persistObject.MonthlyPaymentAmount; } // Store the parameter for the PayoffStatusIndicator attribute. sqlparams["@payoffStatusIndicator"].Value = persistObject.PayoffStatusIndicator; // Store the parameter for the PayoffWithCurrentAssetsIndicator attribute. sqlparams["@payoffWithCurrentAssetsIndicator"].Value = persistObject.PayoffWithCurrentAssetsIndicator; // Store the parameter for the RemainingTermMonths attribute. if (!persistObject.RemainingTermMonthsIsNull) { sqlparams["@remainingTermMonths"].Value = persistObject.RemainingTermMonths; } // Store the parameter for the Type attribute. sqlparams["@type"].Value = persistObject.Type; // Store the parameter for the UnpaidBalanceAmount attribute. if (!persistObject.UnpaidBalanceAmountIsNull) { sqlparams["@unpaidBalanceAmount"].Value = persistObject.UnpaidBalanceAmount; } // Store the parameter for the SubjectLoanResubordinationIndicator attribute. sqlparams["@subjectLoanResubordinationIndicator"].Value = persistObject.SubjectLoanResubordinationIndicator; // Store the parameter for the Id attribute. if (!persistObject.Persisted) { // store the create only (historical fixed) values } else { // store the update only (historical changeable) values // Store the parameter for the Id attribute. sqlparams["@id"].Value = persistObject.Id; } if (sqlTrans == null) { // Process using the isolated connection using (cnn) { // open the connection cnn.Open(); if (!persistObject.Persisted) { persistObject._id = Convert.ToInt64(SqlHelper.ExecuteScalar(cnn, CommandType.StoredProcedure, "gsp_CreateLiability", sqlparams)); } else { SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure, "gsp_UpdateLiability", sqlparams); } // close the connection after usage cnn.Close(); } // nullify the connection var cnn = null; } else { // Process using the shared transaction if (!persistObject.Persisted) { persistObject._id = Convert.ToInt64(SqlHelper.ExecuteScalar(sqlTrans, CommandType.StoredProcedure, "gsp_CreateLiability", sqlparams)); } else { SqlHelper.ExecuteNonQuery(sqlTrans, CommandType.StoredProcedure, "gsp_UpdateLiability", sqlparams); } } } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// Persists the object. /// </summary> public virtual void Persist(Liability persistObject) { // Make a call to the overloaded method with a null transaction Persist(persistObject, null); }
public bool AddLiability(Liability _objLiabilityDetails) { return(Repository.AddLiability(_objLiabilityDetails)); }
public bool UpdateLiabilityDetails(Liability _objLiabilityDetails) { return(Repository.UpdateLiabilityDetails(_objLiabilityDetails)); }
public tlrBF3(DataSet dataSet, string fromMonth, string fromYear, string toMonth, string toYear) { double Equity, Liability, Property, TradeBalance, Loans, Investments, Cash, Assets; Equity = Liability = Property = TradeBalance = Loans = Investments = Cash = Assets = 0.0; InitializeComponent(); //txtFinancialEnded.Value = string.Format("(For financial year ended 31/12/{0})", toYear); //txtFinEndDate.Value = string.Format("{5} 1/{0}/{1} To {2}/{3}/{4}", fromMonth, fromYear, System.DateTime.DaysInMonth(int.Parse(toYear), int.Parse(toMonth)), toMonth, toYear, txthead.Value); txtCompanyCode.Value = string.Format(": {0}", dataSet.Tables[0].Rows[0]["pCode"].ToString()); txtCompanyName.Value = string.Format(": {0}", dataSet.Tables[0].Rows[0]["pName"].ToString()); //DateTime fdate = DateTime.Parse(dataSet.Tables[0].Rows[0]["FinancialEnd"].ToString()); // DateTime fdate = DateTime.Parse(dataSet.Tables[0].Rows[0]["FinancialEnd"].ToString()); DateTime pdate = DateTime.Parse(dataSet.Tables[0].Rows[0]["printTime"].ToString()); txtFinEndDate.Value = string.Format("As at {0}/{1}/{2}", System.DateTime.DaysInMonth(int.Parse(fromYear), int.Parse(fromMonth)), fromMonth, fromYear); //txtFinEndDate.Value = string.Format("As at {0}/{1}/{2}", System.DateTime.DaysInMonth(fdate.Year, fdate.Month), fdate.Month, fdate.Year); txtPrintDate.Value = string.Format("Date Printed {0}/{1}/{2} {3}:{4}:{5}", pdate.Day, pdate.ToString("MMM"), pdate.Year, pdate.Hour, pdate.Minute, pdate.Second); for (int count = 1; count < dataSet.Tables.Count; count++) { Telerik.Reporting.TextBox txtN = detail.Items.Find(string.Format("txt{0}n", count), true)[0] as Telerik.Reporting.TextBox; Telerik.Reporting.TextBox txtR = detail.Items.Find(string.Format("txt{0}r", count), true)[0] as Telerik.Reporting.TextBox; txtN.Value = dataSet.Tables[count].Rows[0]["ColumnName"].ToString(); string result = dataSet.Tables[count].Rows[0]["Result"].ToString(); if (count == 1) { Equity = double.Parse(dataSet.Tables[2].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[3].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[4].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[5].Rows[0]["Result"].ToString()); result = Equity.ToString("#0.00"); } if (count == 6) { Liability = double.Parse(dataSet.Tables[7].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[8].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[9].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[10].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[11].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[12].Rows[0]["Result"].ToString()); result = Liability.ToString("#0.00"); } if (count == 13) { Property = double.Parse(dataSet.Tables[14].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[15].Rows[0]["Result"].ToString()); result = Property.ToString("#0.00"); } if (count == 16) { Loans = double.Parse(dataSet.Tables[16].Rows[0]["Result"].ToString()); result = Loans.ToString("#0.00"); } if (count == 17) { Investments = double.Parse(dataSet.Tables[17].Rows[0]["Result"].ToString()); result = Investments.ToString("#0.00"); } if (count == 18) { Cash = double.Parse(dataSet.Tables[18].Rows[0]["Result"].ToString()); result = Cash.ToString("#0.00"); } if (count == 19) { TradeBalance = double.Parse(dataSet.Tables[21].Rows[0]["Result"].ToString()) + double.Parse(dataSet.Tables[22].Rows[0]["Result"].ToString()); Assets = TradeBalance + double.Parse(dataSet.Tables[23].Rows[0]["Result"].ToString()); result = Assets.ToString("#0.00"); } if (count == 20) { result = TradeBalance.ToString("#0.00"); } txtR.Value = result; } txtTotalLiabil.Value = (Equity + Liability).ToString("#0.00"); txtTotalAssets.Value = (Property + Loans + Investments + Cash + Assets).ToString("#0.00"); }
/// <summary> /// Saves a liability account to the data store. /// </summary> /// <param name="liability">The liability to save.</param> public override void PersistLiability(Liability liability) { SaveAccount(liability); }