public async Task <IActionResult> New(MonafastViewModel model) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(model); Monafsa monafsa = new Monafsa { Name = model.Name, EngineerId = model.EngineerId, LastDate = model.LastDate, PdfFile = uniqueFileName, Advertiser = model.Advertiser, Note = model.Note, Price = model.Price, Sadad = model.Sadad, StatuId = model.StatuId }; dbContext.Add(monafsa); await dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ItemCode,Name,Count,Price,BuyPrice,MonafsaId,UnitsId")] Item item) { if (id != item.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemExists(item.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Monafsa), new { id = item.MonafsaId })); } ViewData["MonafsaId"] = new SelectList(_context.Monafsas, "Id", "Name", item.MonafsaId); ViewData["UnitsId"] = new SelectList(_context.Units, "Id", "Name", item.UnitsId); return(View(item)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Statu statu) { if (ModelState.IsValid) { _context.Add(statu); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(statu)); }
public async Task <IActionResult> Create([Bind("Id,Name,Advertiser,LastDate,Price,StatuId,EngineerId,Sadad")] Monafsa monafsa) { if (ModelState.IsValid) { _context.Add(monafsa); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EngineerId"] = new SelectList(_context.Engineers, "Id", "Id", monafsa.EngineerId); ViewData["StatuId"] = new SelectList(_context.Status, "Id", "Id", monafsa.StatuId); return(View(monafsa)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Advertiser,LastDate,Price,StatuId,EngineerId,Sadad,Note,PdfFile")] Monafsa monafsa) { if (id != monafsa.Id) { return(NotFound()); } if (ModelState.IsValid) { try { context.Update(monafsa); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MonafsaExists(monafsa.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { id = monafsa.Id })); } ViewData["EngineerId"] = new SelectList(context.Engineers, "Id", "Name", monafsa.EngineerId); ViewData["StatuId"] = new SelectList(context.Status, "Id", "Name", monafsa.StatuId); return(View(monafsa)); }