public async Task <ActionResult> DeleteConfirmed(int id) { LicenseTable licenseTable = await db.LicenseTables.FindAsync(id); db.LicenseTables.Remove(licenseTable); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// GET: LicenseTables/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LicenseTable licenseTable = await db.LicenseTables.FindAsync(id); if (licenseTable == null) { return(HttpNotFound()); } return(View(licenseTable)); }
public async Task <ActionResult> Create([Bind(Include = "Id,ClientName,SoftwareVersion,ApprovedKey,ValidityFrom,ValidityTo,ApprovedDocument,ApprovedBy,CreatedBy,CreatedOn,ModifiedBy,ModifiedOn")] LicenseTable licenseTable, HttpPostedFileBase file) { if (ModelState.IsValid) { try { string fileName = string.Empty; string filePath = string.Empty; if (file.ContentLength > 0 && file != null) { filePath = file.FileName; fileName = Path.GetFileName(file.FileName); } else { ViewBag.Error = " please select approved document to continue."; return(View(licenseTable)); } var folderPath = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/LicenseDocs"; var fullFilePath = Path.Combine(folderPath, filePath); file.SaveAs(fullFilePath); licenseTable.ApprovedDocument = fileName; licenseTable.IsExpired = false; licenseTable.IsLicensed = true; licenseTable.ApprovedKey = LegalGuideUtility.Encrypt(licenseTable.ApprovedKey); licenseTable.SoftwareVersion = licenseTable.SoftwareVersion.ToString(); licenseTable.CreatedBy = User.Identity.Name; licenseTable.CreatedOn = DateTime.Today; db.LicenseTables.Add(licenseTable); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = "Can't Save License info please check and try again." + ex.Message; } } else { ViewBag.Error = "Can't Save License info, Some fields are missing"; return(View(licenseTable)); } return(View(licenseTable)); }