public async Task <IActionResult> Edit(int id, [Bind("ErrId,ErrMessage,ErrDate,ErrPageName,ErrLine,ErrDetails")] ErrorTb errorTb) { if (id != errorTb.ErrId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(errorTb); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ErrorTbExists(errorTb.ErrId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(errorTb)); }
void Delete_Resources(Brands _brands) { try { if (_brands.BrandLogoPicturePath != string.Empty || _brands.BrandLogoPicturePath != null) { string Root_Path = Directory.GetCurrentDirectory(); string FullPath = Path.Combine(Root_Path, "wwwroot", "Images", "BrandsLogo", _brands.BrandLogoPicturePath); if (FullPath != null) { System.IO.File.Delete(FullPath); } } } catch (Exception ex) { int lineNumber = (new System.Diagnostics.StackFrame(0, true)).GetFileLineNumber(); ErrorTb tb = new ErrorTb() { ErrId = (_context.ErrorTb.Select(x => x.ErrId).Max()) + 1, ErrMessage = ex.GetType().Name, ErrDate = DateTime.Now, ErrLine = lineNumber }; _context.Add(tb); _context.SaveChanges(); } }
public async Task <IActionResult> Create([Bind("ErrId,ErrMessage,ErrDate,ErrPageName,ErrLine,ErrDetails")] ErrorTb errorTb) { if (ModelState.IsValid) { _context.Add(errorTb); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(errorTb)); }
void SaveCatg_Image(Categories _Catg, IFormFile _Imag) { try { string ImagePath = string.Empty; string FileExtension = ""; if (_Imag != null) { if (_Imag.Length > 0) { FileExtension = Path.GetExtension(_Imag.FileName); ImagePath = Directory.GetCurrentDirectory(); ImagePath = Path.Combine(ImagePath, "wwwroot", "Images", "CatagoriesPic", $"{_Catg.CategoryId}{FileExtension}"); FileStream fs = new FileStream(ImagePath, FileMode.Create); _Imag.CopyTo(fs); fs.Close(); } _Catg.CategoryPicturePath = $"{_Catg.CategoryId}{FileExtension}"; } else { _Catg.CategoryPicturePath = ""; } } catch (Exception ex) { int lineNumber = (new System.Diagnostics.StackFrame(0, true)).GetFileLineNumber(); ErrorTb err = new ErrorTb() { ErrDate = DateTime.Now, ErrId = (_context.ErrorTb.Select(x => x.ErrId).Max()) + 1, ErrMessage = ex.GetType().Name, ErrLine = lineNumber, }; _context.ErrorTb.Add(err); _context.SaveChanges(); } }