// GET: Income public ActionResult Index() { var incomeList = _incomeService.GetByContextId(GetCurrentContextId()); var viewModelList = new ListAllIncomeViewModel(); //viewModelList.Currency = incomeList.First().Context.CurrencyType.Symbol; viewModelList.Currency = "€"; foreach (var income in incomeList) { var viewModel = new IncomeViewModel() { Description = income.Description, BankAccountId = income.BankAccountId, BankAccount = income.BankAccount.Name, Category = income.Category.Name, CategoryId = income.CategoryId, Context = income.Context.Name, ContextId = income.ContextId, CreationDate = income.CreationDate, Date = income.Date, Id = income.Id, Observation = income.Observation, Received = income.Received, Value = income.Value, }; viewModelList.IncomeList.Add(viewModel); } return(View(viewModelList)); }
public UIElement GetIncomeElement() { IncomeViewModel viewModel = new IncomeViewModel(facade); IncomeControl control = new IncomeControl(viewModel); return(control); }
public IActionResult EditIncome([FromBody] IncomeViewModel viewModel) { var validation = ValidateData(viewModel); if (!string.IsNullOrWhiteSpace(validation)) { return(BadRequest(validation)); } var income = FetchIncome(viewModel.Id); if (income == null) { TempData["Error"] = "Something went wrong."; return(View("IncomeForm", viewModel)); } TempData["Success"] = "Sėkmingai atnaujintos pajamos!"; UpdateIncome(income, viewModel); var incomeList = FetchUserIncomeList(); return(View("IncomeList", new IncomeListViewModel() { Income = incomeList })); }
// GET: Salary/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IncomeViewModel incomeVM = new IncomeViewModel(); incomeVM.EventArgument = EventArgumentEnum.Delete; incomeVM.EventCommand = EventCommandEnum.Get; incomeVM.Entity.Paycheck.Id = (int)id; if (incomeVM.HandleRequest()) { return(View(incomeVM)); } return(HttpNotFound()); //if (salary == null) //{ // return HttpNotFound(); //} //return View(salary); }
public ActionResult Entry(IncomeViewModel income) { IncomeModel data = new IncomeModel(); #region Income Model data maping data.Amount = income.Amount; data.BankId = income.BankId; data.Date = income.Date; data.Particular = income.Particular; data.ChequeNo = income.ChequeNo; if (income.isCash == 1) { data.Cash = true; } else { data.Cheque = true; } #endregion bool isSaved = IncomeManager.SaveIncome(data); if (isSaved) { ViewBag.Message = "Income Saved"; } ViewBag.BankList = BankManager.LoadBank(); return(View()); }
// GET: Income/Create public ActionResult Create(IncomeViewModel model = null) { PrepareLookups(model); return(View("Create")); }
private void PrepareLookups(IncomeViewModel model) { IncomeViewModel vm = model ?? new IncomeViewModel(); ClaimsPrincipal currentUser = User; var userId = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value; List <SelectListItem> accountidlist = vm.GetAccountList(userId); List <SelectListItem> items = new List <SelectListItem>(); foreach (var el in accountidlist) { items.Add(new SelectListItem { Text = el.Text, Value = el.Value }); } ViewBag.accountidlist = items; List <SelectListItem> categorylist = vm.GetCategoryIncomeList(userId); List <SelectListItem> categories = new List <SelectListItem>(); foreach (var el in categorylist) { categories.Add(new SelectListItem { Text = el.Text, Value = el.Value }); } ViewBag.categorylist = categories; }
public ActionResult Edit(IncomeViewModel CVM) { IncomeClient client = new IncomeClient(); client.Edit(CVM.Income); return(RedirectToAction("Index")); }
public ActionResult Create(IncomeViewModel incomeVM) { if (!ModelState.IsValid) { return(View(incomeVM)); } incomeVM.EventArgument = EventArgumentEnum.Create; incomeVM.Entity.Paycheck.Date = Convert.ToDateTime(incomeVM.Date); incomeVM.Entity.AutoTransferPaycheckContributions = incomeVM.AutoTransferPaycheckContributions; if (incomeVM.HandleRequest()) { return(RedirectToAction("Index")); } return(View(incomeVM)); //var newSalary = new Salary() //{ // NetIncome = salary.NetIncome, // PayFrequency = salary.PayFrequency, // Payee = salary.Payee, // GrossPay = salary.GrossPay, // PayTypesEnum = salary.PayTypesEnum //}; //_db.Salaries.Add(newSalary); //_db.SaveChanges(); }
public ActionResult Index(string sort, DateTime?dateFrom, DateTime?dateTo, int?categoryId) { if (dateFrom != null && dateTo != null) { ViewBag.DateFrom = dateFrom; ViewBag.DateTo = dateTo; } ViewBag.Sort = "desc"; ViewBag.Sort = !String.IsNullOrEmpty(sort) && sort == "asc" ? "desc" : "asc"; ViewBag.IncomeCategories = IncomeRepository.Categories; IEnumerable <Incomes> incomes = incomeRepository.GetAllIncomesByUser(User.Identity.GetUserId(), dateFrom, dateTo, categoryId, sort); List <IncomeViewModel> incomeViewModel = new List <IncomeViewModel>(); foreach (var item in incomes) { var viewModelItem = new IncomeViewModel { Id = item.Id, Category = incomeRepository.GetCategoryNameById(item.CategoryId), Date = item.Date, Name = item.Name, Value = item.Value }; incomeViewModel.Add(viewModelItem); } return(View(incomeViewModel)); }
public ActionResult Search(string query) { //TODO: improve code quality and introduce service int month; if (!int.TryParse(query, out month)) { return(this.View(nameof(this.Details))); } var orders = this.orderService.All().To <OrdersViewModel>().Where(x => x.CreatedOn.Month == month).ToList(); var viewModel = new IncomeViewModel { TotalForMonth = orders.Sum(x => x.OrderPrice), TotalForKornelia = orders.Where(x => x.Creator == "Корнелия").Sum(x => x.OrderPrice), TotalForMitko = orders.Where(x => x.Creator == "Митко").Sum(x => x.OrderPrice), TotalForNikola = orders.Where(x => x.Creator == "Никола").Sum(x => x.OrderPrice), TotalForStaiko = orders.Where(x => x.Creator == "Стайко").Sum(x => x.OrderPrice) }; return(this.View(nameof(this.Details), viewModel)); }
public async Task <IActionResult> Create() { var accessToken = await HttpContext.GetTokenAsync("access_token"); var content = await _incomeCategoryRepository.GetIncCategory ("https://localhost:44382/IncomeCategory/Get", accessToken); var incomeViewModel = new IncomeViewModel(); if (content == "Unauthorized") { return(RedirectToAction("Logout", "Home")); } else { var incomeCategories = _incomeCategoryRepository. DeseralizeIncCategories (content); incomeViewModel.Categories = from NameOfCategory in incomeCategories select new SelectListItem { Text = NameOfCategory.Name, Value = NameOfCategory.Name.ToString() }; return(View(incomeViewModel)); } }
public ActionResult Details(int id) { using (var db = new SmDbContext()) { var entity = db.Incomes.First(x => x.Id == id); var model = new IncomeViewModel { DocumentNumber = entity.DocumentNumber, Id = entity.Id, IncomeDate = entity.IncomeDate, Operator = entity.Operator.Lastname + " " + entity.Operator.Firstname, SupplierId = entity.SupplierId, Supplier = entity.Supplier.Name, Processed = entity.Processed }; model.IncomeItems = db.IncomeItems.Where(x => x.IncomeId == id).Select(x => new IncomeItemViewModel { Id = x.Id, Amount = x.Amount, Price = x.Price, GoodsId = x.GoodsId, GoodsBrand = x.Goods.Brand, GoodsCategory = x.Goods.GoodsCategory.Name, GoodsName = x.Goods.Name, GoodsSubCategory = x.Goods.GoodsSubCategory == null ? "" : x.Goods.GoodsSubCategory.Name, }).ToArray(); return(View(model)); } }
public IActionResult Create(IncomeViewModel tax) { using var httpClient = new HttpClient(_clientHandler); var content = new StringContent(JsonConvert.SerializeObject(tax), Encoding.UTF8, "application/json"); using var response = httpClient.PostAsync("http://localhost:5000/api/TaxValue", content) .Result; if (response.StatusCode == HttpStatusCode.OK) { var apiResponse = JsonConvert.DeserializeObject <ApiResponse>(response.Content.ReadAsStringAsync() .Result); if (apiResponse.Success) { var values = (apiResponse.Result as JObject).ToObject <TaxValue>(); return(Ok(values)); } return(BadRequest(apiResponse.Message)); } _logger.LogError(response.ToString()); return(BadRequest(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier })); }
public ActionResult Income(int?Month) { if (Month > 0) { int shopid = Convert.ToInt32(Session["Shop"].ToString()); var orderDetails = db.OrderDetails.Where(p => p.Product.ShopID == shopid && p.Order.OrderDate.Month == Month).ToList(); if (orderDetails != null) { var result = new IncomeViewModel { Items = orderDetails, Total = Calcuate(orderDetails), }; return(View(result)); } ViewBag.Message = "No Record Found"; return(View()); } else { ViewBag.Message = "Select Month"; return(View()); } }
public async Task <IActionResult> Put(IncomeViewModel model) { //Validate the model if (ModelState.IsValid) { //Get the income var income = await db.Incomes.FindAsync(model.Id); if (income == null) { return(NotFound()); } //Get the money type var moneyType = await db.MoneyTypes.FindAsync(model.MoneyTypeId); if (moneyType == null) { return(NotFound()); } //Get the category var category = await db.Categories.FindAsync(model.CategoryId); if (category == null) { return(NotFound()); } //Get the provider var provider = await db.Providers.FindAsync(model.ProviderId); if (provider == null) { return(NotFound()); } //Update income data income.Title = model.Title; income.Description = model.Description; income.Amount = model.Amount; income.PayDate = model.PayDate; income.ProvidedId = provider.Id; income.CategoryId = category.Id; income.MoneyTypeId = moneyType.Id; //Save changes to the database await db.SaveChangesAsync(); return(Ok(new HttpSingleResponse <Income> { IsSuccess = true, Message = "Income has been updated successfully.", Value = income })); } return(this.FixedBadRequest("Model sent has some errors.")); }
// GET: Income public ActionResult Index() { Guid userGuid = new Guid(User.Identity.GetUserId()); IncomeViewModel vm = new IncomeViewModel(userGuid); //ListPaychecksViewModel vm = new ListPaychecksViewModel(userGuid); return(View(vm)); }
public ActionResult Edit(int id) { Income income = daoTemplate.FindByID <Income>(id); IncomeViewModel viewModel = IncomeViewModel.From(income); viewModel.Products = Products(); return(View(viewModel)); }
public ActionResult Add() { IncomeViewModel viewModel = new IncomeViewModel(); viewModel.Products = Products(); return(View(viewModel)); }
// GET: Income/Edit/5 public ActionResult Edit(int id) { IncomeClient client = new IncomeClient(); IncomeViewModel CVM = new IncomeViewModel(); CVM.Income = client.Find(id); PrepareLookups(CVM); return(View("Edit", CVM)); }
//private readonly ApplicationDbContext _db = new ApplicationDbContext(); // GET: Salary public ActionResult Index() { IncomeViewModel incomeVM = new IncomeViewModel(); incomeVM.EventArgument = EventArgumentEnum.Read; incomeVM.EventCommand = EventCommandEnum.Get; incomeVM.HandleRequest(); return(View(incomeVM)); }
public ViewResult List() { IncomeViewModel incomes = new IncomeViewModel { Incomes = _repository.Incomes.OrderByDescending(i => i.Date) }; return(View(incomes)); }
public Page3() { InitializeComponent(); IncomeViewModel vm = new IncomeViewModel(); Label1.Text = vm.listIncome.sumin; Label2.Text = vm.listIncome.sumex; Label3.Text = vm.listIncome.total; }
public int AddIncome(IncomeViewModel incomeViewModel) { try { return(_incomeService.Add(new IncomeControllerHelper().MapIncomeViewModelToDTO(incomeViewModel))); } catch (Exception ex) { _logger.Error(ex); throw; } }
private void UpdateIncome(Income income, IncomeViewModel viewModel) { income.Amount = viewModel.Amount.Value; income.Comment = viewModel.Comment; income.Source = viewModel.Source; income.UpdateDate = DateTime.UtcNow; income.Category = repository.Categories.FirstOrDefault(x => x.Id == viewModel.CategoryId); repository.Update(income); repository.SaveChanges(); }
public ActionResult Income() { int shopid = Convert.ToInt32(Session["Shop"].ToString()); var orderDetails = db.OrderDetails.Where(p => p.Product.ShopID == shopid).ToList(); var result = new IncomeViewModel { Items = orderDetails, Total = Calcuate(orderDetails), }; return(View(result)); }
public ActionResult DeleteConfirmed(int id) { IncomeViewModel incomeVM = new IncomeViewModel(); incomeVM.EventArgument = EventArgumentEnum.Delete; incomeVM.EventCommand = EventCommandEnum.Delete; incomeVM.Entity.Paycheck.Id = id; incomeVM.HandleRequest(); //Salary salary = _db.Salaries.Find(id); //_db.Salaries.Remove(salary); //_db.SaveChanges(); return(RedirectToAction("Index")); }
public IncomeViewModel GetIncomes() { var allExpenses = new IncomeViewModel(); using (var DataContext = new Entities()) { foreach (var budgetItem in DataContext.Incomes) { allExpenses.Incomes.Incomes.Add(new IncomeItem(id: Convert.ToInt32(budgetItem.Id), amount: Convert.ToDecimal(budgetItem.Amount), description: budgetItem.Description, frequency: Convert.ToChar(budgetItem.Frequency), user_id: budgetItem.User_Id)); } } return(allExpenses); }
public ActionResult EditIncome(IncomeViewModel incomeViewModel) { try { _incomeService.Edit(new IncomeControllerHelper().MapIncomeViewModelToDTO(incomeViewModel)); return(Json(JsonRequestBehavior.AllowGet)); } catch (Exception ex) { _logger.Error(ex); throw; } }
public static Income Map(IncomeViewModel incomeVm) { string description = HtmlEncoder.Default.Encode(incomeVm.Description); return(new Income { Description = description, Value = incomeVm.Value, Category = new Category() { CategoryId = incomeVm.Category } }); }