public async Task <IActionResult> ComputerAccessoriesBrand([FromForm] DocumentTypeViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile); if (message == "success") { attachPath = fileName; } } ComputerAccessoriesBrand computerAccessoriesBrand = new ComputerAccessoriesBrand { Id = (int)model.documentcategoryId, brandName = model.documentCategoryName, brandNameBn = model.documentCategoryNameBn, imagePath = attachPath }; await lostAndFoundType.SaveComputerAccessoriesBrand(computerAccessoriesBrand); return(RedirectToAction(nameof(ComputerAccessoriesBrand))); }
public async Task <int> SaveComputerAccessoriesBrand(ComputerAccessoriesBrand computerAccessoriesBrand) { if (computerAccessoriesBrand.Id != 0) { _context.ComputerAccessoriesBrands.Update(computerAccessoriesBrand); await _context.SaveChangesAsync(); return(1); } else { await _context.ComputerAccessoriesBrands.AddAsync(computerAccessoriesBrand); await _context.SaveChangesAsync(); return(1); } }