public async Task <IActionResult> Create([Bind("Id,Fname,Lname,Group,City")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("Id,Card,Suma,Km,Km_gps,L,Start,End")] Report report) { if (ModelState.IsValid) { _context.Add(report); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(report)); }
public async Task <IActionResult> Create([Bind("Id,Make,Model,NumberPlate")] Car car) { if (ModelState.IsValid) { _context.Add(car); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(car)); }
public async Task <IActionResult> Create([Bind("Id, gsReport")] kuras.ViewModels.FileUploadViewModel upload) { if (ModelState.IsValid) { string uniqueFileName = null; if (upload.gsReport != null) { string uploadsFolder = Path.Combine(webhostEnvironment.WebRootPath, "reports"); DateTime a = DateTime.Now; char[] date_now = new char[a.ToString().Length]; int i = 0; foreach (char b in a.ToString()) { if (b == ' ' || b == '/') { date_now[i] = '_'; } else if (b == ':') { date_now[i] = ';'; } else { date_now[i] = b; } i++; } string temp_string_date = new string(date_now); uniqueFileName = "date-" + temp_string_date + "__" + upload.gsReport.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); upload.gsReport.CopyTo(new FileStream(filePath, FileMode.Create)); } Test test = new Test { FileName = uniqueFileName }; _context.Add(test); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(upload)); }
public async Task <IActionResult> Create([Bind("Id, gsReport")] kuras.ViewModels.FileUploadViewModel model) { if (ModelState.IsValid) { string webroot = webhostEnvironment.WebRootPath; GasStationFile fileObj = Methods.GlobalMethods.UploadFile(model, "remainingfuel", webroot); RemainingFuelFile rfObj = new RemainingFuelFile { FileName = fileObj.FileName, Uploaded = false }; if (rfObj != null) { _context.Add(rfObj); await _context.SaveChangesAsync(); return(RedirectToAction("Show", new { id = rfObj.Id })); } else { return(NotFound()); } } else { return(NotFound()); } }
public async Task <IActionResult> DeleteConfirmed(int id) { var kilometersFile = await _context.KilometersFile.FindAsync(id); string webroot = webhostEnvironment.WebRootPath; string folderName = "kilometers"; string folderPath = Path.Combine(webroot, folderName); bool wasDeleted = kuras.Methods.GlobalMethods.DeleteFile(kilometersFile.FileName, folderPath); if (wasDeleted) { _context.KilometersFile.Remove(kilometersFile); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("Id,Car,Emp,Number,Limit")] Card card) { if (ModelState.IsValid) { _context.Add(card); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(card)); }
public async Task <IActionResult> Delete([Bind("Id")] int id) { var card = await _kuras_context.Axapta.FindAsync(id); if (card != null) { _kuras_context.Axapta.Remove(card); await _kuras_context.SaveChangesAsync(); return(RedirectToAction(nameof(Refine))); } else { return(NotFound()); } }
// INSERT DATA // GET: GasStation/Insert/5 public async Task <IActionResult> Insert(int?id) { //if no such id if (id == null) { return(NotFound()); } var gasStationFile = await _context.GasStationFile .FirstOrDefaultAsync(m => m.Id == id); //if no data in that id if (gasStationFile == null) { return(NotFound()); } if (gasStationFile.FileName != null) { //returns var Data = GasStationReport(gasStationFile.FileName); if (Data.Any()) { foreach (var el in Data) { _context.Add(el); } gasStationFile.Uploaded = true; _context.Update(gasStationFile); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { return(NotFound()); } } return(View()); }