public async Task <IActionResult> Edit(int id, [Bind("UtilajModelID,Utilaj,ZonaUtilaj")] UtilajModel utilajModel) { if (id != utilajModel.UtilajModelID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(utilajModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UtilajModelExists(utilajModel.UtilajModelID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(utilajModel)); }
public async Task <IActionResult> Create([Bind("UtilajModelID,Utilaj,ZonaUtilaj")] UtilajModel utilajModel) { if (ModelState.IsValid) { _context.Add(utilajModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(utilajModel)); }
public async Task <IActionResult> Create([Bind("ProblemaModelID,DataIntroducere,UtilajModelID,ProblemaDescriere,ComentariuMentenanta,LastPersonUpdateRow")] ProblemaModel problemaModel) { if (ModelState.IsValid) { problemaModel.ComentariuMentenanta = "-"; problemaModel.Stare = Status.Nerezolvat; _context.Add(problemaModel); await _context.SaveChangesAsync(); // Send Mail string filePathMailModel = Path.Combine(_env.WebRootPath, "Fisiere\\MailDate.JSON"); MailModel mailModel = _emailSender.GetMailModelAsync(filePathMailModel).Result; UtilajModel utilajName = _context.UtilajModels.FirstOrDefault(utilaj => utilaj.UtilajModelID == problemaModel.UtilajModelID); await _emailSender.SendEmailAsync(mailModel.FromAdress, mailModel.ToAddress, mailModel.Subjsect, problemaModel.LastPersonUpdateRow + mailModel.Messaege + problemaModel.ProblemaDescriere + $" la utilajul: {utilajName.Utilaj}"); return(RedirectToAction(nameof(Index))); } ViewData["ResponsabilModelID"] = new SelectList(_context.ResponsabilModel, "ResponsabilModelID", "Email", problemaModel.ResponsabilModelID); ViewData["UtilajModelID"] = new SelectList(_context.UtilajModels, "UtilajModelID", "Utilaj", problemaModel.UtilajModelID); return(View(problemaModel)); }