public IActionResult GetTodayOffice(DateTime Date) { var date = Date.ToShortDateString(); OfficeVM model = new OfficeVM(); // income model.Commisions = _context.BoatOwnerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.Commission); model.IsellerReceiptsTotal = (decimal)_context.ISellerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.PaidFromDebt); model.externalReceiptsTotal = _context.ExternalReceipts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.FinalIncome); model.SharedBoatsReceiptsTotal = _context.BoatOwnerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.FinalIncome); model.collectorForUsTotal = _context.PaidForMerchant.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3 && x.IsPaidForUs == true).Sum(x => x.Payment); model.LeaderLoansPaybackTotal = _context.LeaderPaybacks.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.Price); model.SalesTotal = (decimal)_context.ISellerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.PaidFromDebt); model.CheckoutsOfSharedBoats = (decimal)_context.Checkouts.ToList().Where(c => c.Date.ToShortDateString() == date).Sum(c => c.PaidForUs); //outcome model.FathallahTotal = _context.FathAllahGifts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.charge); model.CollectorTotalFromUs = _context.PaidForMerchant.Include(x => x.Merchant).ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 1 && x.IsPaidForUs == true && x.Merchant.IsOwner == true).Sum(x => x.Payment); var CollectorPaidForMerchant = _context.PaidForMerchant.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3 && x.IsPaidForUs == false).Sum(x => x.Payment); var CollectorPaidForHalek = _context.Debts_Sarhas.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3).Sum(x => x.Price); var CollectorPaidForFathallah = _context.FathAllahGifts.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3).Sum(x => x.charge); var CollectorPaidForAdditional = _context.AdditionalPayments.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.Value); model.CollectorTotalforMerchantsAndHalek = CollectorPaidForMerchant + CollectorPaidForHalek + CollectorPaidForFathallah + CollectorPaidForAdditional; var totalOfProfit = _context.TotalOfProfits.ToList().Where(x => x.Date.ToShortDateString() == date).FirstOrDefault(); var carPrices = _context.ISellerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.CarPrice); if (totalOfProfit != null) { model.BuyingTotal = Convert.ToDecimal(totalOfProfit.TotalOfSales + totalOfProfit.Labour + totalOfProfit.Ice + carPrices); } else { model.BuyingTotal = 0.0m; } var totalIncome = model.Commisions + model.IsellerReceiptsTotal + model.externalReceiptsTotal + model.SharedBoatsReceiptsTotal + model.collectorForUsTotal + model.LeaderLoansPaybackTotal + model.SalesTotal + model.CheckoutsOfSharedBoats; var totalOutcome = model.FathallahTotal + model.CollectorTotalFromUs + model.CollectorTotalforMerchantsAndHalek + model.BuyingTotal; return(Json(new { message = "success", commisions = model.Commisions, isellerReceiptsTotal = model.IsellerReceiptsTotal, externalReceiptsTotal = model.externalReceiptsTotal, sharedBoatsReceiptsTotal = model.SharedBoatsReceiptsTotal, collectorForUsTotal = model.collectorForUsTotal, leaderLoansPaybackTotal = model.LeaderLoansPaybackTotal, salesTotal = model.SalesTotal, fathallahTotal = model.FathallahTotal, collectorTotalFromUs = model.CollectorTotalFromUs, collectorTotalforMerchantsAndHalek = model.CollectorTotalforMerchantsAndHalek, buyingTotal = model.BuyingTotal, credit = _context.People.Find(1).credit, totalIncome = totalIncome, totalOutcome = totalOutcome, finalTotal = totalIncome - totalOutcome })); }
public ActionResult <ResponseVM> Create ([FromBody] OfficeVM officeVM) { if (!ModelState.IsValid) { return(BadRequest("something went wrong")); } return(officeService.Create(officeVM)); }
public async Task EditOffice(OfficeVM office) { OfficeQueue officeQueue = Mapper.Map <OfficeVM, OfficeQueue>(office, options => { options.AfterMap((src, dest) => dest.UserPerformingAction = this.UserId); options.AfterMap((src, dest) => dest.TenantId = this.TenantId); }); ProcessQueueHistory processQueueHistory = new ProcessQueueHistory() { Data = JsonConvert.SerializeObject(officeQueue), AddedById = this.UserId, TenantId = this.TenantId, Status = Data.Enums.ResultStatus.Waiting, Type = Data.Enums.ProcessType.EditOffice }; await this.queueHandler.AddToQueue(processQueueHistory); }
public IActionResult Office() { var date = TimeNow().ToShortDateString(); OfficeVM model = new OfficeVM(); // income model.Commisions = _context.BoatOwnerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.Commission); //the same ? model.IsellerReceiptsTotal = (decimal)_context.ISellerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.PaidFromDebt); model.SalesTotal = (decimal)_context.ISellerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.PaidFromDebt); model.externalReceiptsTotal = _context.ExternalReceipts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.FinalIncome); model.SharedBoatsReceiptsTotal = _context.IncomesOfSharedBoats.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.Income); model.collectorForUsTotal = _context.PaidForMerchant.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3 && x.IsPaidForUs == true).Sum(x => x.Payment); model.LeaderLoansPaybackTotal = _context.LeaderPaybacks.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.Price); model.CheckoutsOfSharedBoats = (decimal)_context.Checkouts.ToList().Where(c => c.Date.ToShortDateString() == date).Sum(c => c.PaidForUs); //outcome model.FathallahTotal = _context.FathAllahGifts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.charge); model.CollectorTotalFromUs = _context.PaidForMerchant.Include(x => x.Merchant).ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 1 && x.IsPaidForUs == true && x.Merchant.IsOwner == true).Sum(x => x.Payment); var CollectorPaidForMerchant = _context.PaidForMerchant.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3 && x.IsPaidForUs == false).Sum(x => x.Payment); var CollectorPaidForHalek = _context.Debts_Sarhas.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3).Sum(x => x.Price); var CollectorPaidForHalekFromFathallahAndMohamed = _context.Debts_Sarhas.ToList().Where(x => x.Date.ToShortDateString() == date && (x.PersonID == 3 || x.PersonID == 4)).Sum(x => x.Price); var CollectorPaidForFathallah = _context.FathAllahGifts.ToList().Where(x => x.Date.ToShortDateString() == date && x.PersonID == 3).Sum(x => x.charge); var CollectorPaidForAdditional = _context.AdditionalPayments.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.Value); model.CollectorTotalforMerchantsAndHalek = CollectorPaidForMerchant + CollectorPaidForHalek + CollectorPaidForFathallah + CollectorPaidForAdditional; var totalOfProfit = _context.TotalOfProfits.ToList().Where(x => x.Date.ToShortDateString() == date).FirstOrDefault(); var carPrices = _context.ISellerReciepts.ToList().Where(x => x.Date.ToShortDateString() == date).Sum(x => x.CarPrice); if (totalOfProfit != null) { model.BuyingTotal = Convert.ToDecimal(totalOfProfit.TotalOfSales + totalOfProfit.Labour + totalOfProfit.Ice + carPrices); } else { model.BuyingTotal = 0.0m; } ViewBag.Credit = _context.People.Find(1).credit; return(View(model)); }
public async Task <IActionResult> Edit([FromBody] OfficeVM office) { await this.OfficeService.EditOffice(office); return(Ok()); }
public async Task <IActionResult> GetById(Guid id) { OfficeVM office = await this.OfficeService.GetOfficeByIdAsync(id); return(Json(office)); }