public async Task <IActionResult> Create(List <IFormFile> files, CustomerVM customervm) { var NameDb = adamUnit.CustomerRepository.Exists(x => x.FirstName == customervm.FirstName); if (NameDb == false) { if (!adamUnit.CustomerRepository.Exists(x => x.Email == customervm.Email)) { if (ModelState.IsValid) { var customer = new Customer(); customer = customervm.ToEntity(); await adamUnit.CustomerRepository.InserAsync(customer); string recordId = customer.Id.ToString(); string webRootPath = _hostingEnvironment.WebRootPath; var state = adamUnit.AttachmentRepository.OnPostUpload(files, recordId, AttachmentOwner.Customers, AttachmentType.Photo, webRootPath); TempData["SuccessMessage"] = "Created Successfully"; return(RedirectToAction(nameof(Index))); } } ViewBag.Email = "Email is exist already"; return(View(customervm)); } ViewBag.Name = "Name is exist already"; return(View(customervm)); }