public async Task <IActionResult> Edit(string id, [Bind("CashflowInId,MoneyTransferOrderId,CashflowInNumber,CashflowInDate,Description,CashRepositoryIdFrom,CashRepositoryIdTo,HasChild,createdAt")] CashflowIn cashflowIn) { if (id != cashflowIn.CashflowInId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cashflowIn); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CashflowInExists(cashflowIn.CashflowInId)) { return(NotFound()); } else { throw; } } TempData["TransMessage"] = "Η Επεξεργασία της εγγραφής παραλαβής," + cashflowIn.CashflowInNumber + " έγινε με Επιτυχία"; return(RedirectToAction(nameof(Index))); } ViewData["moneyTransferOrderId"] = new SelectList(_context.MoneyTransferOrder.Where(x => x.MoneyTransferOrderStatus == MoneyTransferOrderStatus.Open && x.isIssued == true).ToList(), "MoneyTransferOrderId", "MoneyTransferOrderNumber", cashflowIn.MoneyTransferOrderId); ViewData["cashRepositoryIdFrom"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName"); ViewData["cashRepositoryIdTo"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName"); return(View(cashflowIn)); }
// GET: CashflowIn/Create public IActionResult Create() { ViewData["moneyTransferOrderId"] = new SelectList(_context.MoneyTransferOrder.Where(x => x.MoneyTransferOrderStatus == MoneyTransferOrderStatus.Open && x.isIssued == true).ToList(), "MoneyTransferOrderId", "MoneyTransferOrderNumber"); ViewData["cashRepositoryIdFrom"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName"); ViewData["cashRepositoryIdTo"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName"); CashflowIn obj = new CashflowIn(); return(View(obj)); }
public async Task <IActionResult> Create([Bind("CashflowInId,MoneyTransferOrderId,CashflowInNumber,CashflowInDate,Description,CashRepositoryIdFrom,CashRepositoryIdTo,HasChild,createdAt")] CashflowIn cashflowIn) { if (ModelState.IsValid) { //check MoneyTransferOrder CashflowIn check = await _context.CashflowIn.SingleOrDefaultAsync(x => x.MoneyTransferOrderId.Equals(cashflowIn.MoneyTransferOrderId)); if (check != null) { ViewData["StatusMessage"] = "Σφάλμα. Η εντολή μεταφοράς χρημάτων έχει ήδη δημιουργηθεί. " + check.CashflowInNumber; ViewData["MoneyTransferOrderId"] = new SelectList(_context.MoneyTransferOrder.ToList(), "MoneyTransferOrderId", "MoneyTransferOrderNumber"); ViewData["CashRepositoryIdFrom"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName"); ViewData["CashRepositoryIdTo"] = new SelectList(_context.CashRepository, "CashRepositoryId", "CashRepositoryName"); return(View(cashflowIn)); } MoneyTransferOrder to = await _context.MoneyTransferOrder.Where(x => x.MoneyTransferOrderId.Equals(cashflowIn.MoneyTransferOrderId)).FirstOrDefaultAsync(); cashflowIn.CashRepositoryIdFrom = to.CashRepositoryIdFrom; cashflowIn.CashRepositoryIdTo = to.CashRepositoryIdTo; cashflowIn.CashRepositoryFrom = await _context.CashRepository.Include(x => x.Employee).SingleOrDefaultAsync(x => x.CashRepositoryId.Equals(cashflowIn.CashRepositoryIdFrom)); cashflowIn.CashRepositoryTo = await _context.CashRepository.Include(x => x.Employee).SingleOrDefaultAsync(x => x.CashRepositoryId.Equals(cashflowIn.CashRepositoryIdTo)); to.isReceived = true; to.MoneyTransferOrderStatus = MoneyTransferOrderStatus.Completed; _context.Add(cashflowIn); await _context.SaveChangesAsync(); TempData["TransMessage"] = "Η εγγραφή Εισροής " + cashflowIn.CashflowInNumber + " έγινε με Επιτυχία!"; return(RedirectToAction("Details", "CashRepository", new { id = cashflowIn.CashRepositoryIdTo })); } ViewData["MoneyTransferOrderId"] = new SelectList(_context.MoneyTransferOrder, "MoneyTransferOrderId", "MoneyTransferOrderId", cashflowIn.MoneyTransferOrderId); return(View(cashflowIn)); }