/// <summary> /// Gets Customer By Name /// </summary> /// <returns>Customer</returns> public Library.Customer GetCustomerByName(string firstName, string lastName) { using var context = new project0Context(_dbContext); var dbCustomers = context.Customers.First(c => c.FirstName == firstName && c.LastName == lastName); var customer = new StoreApp.Library.Customer(dbCustomers.CustomerId, dbCustomers.FirstName, dbCustomers.LastName, dbCustomers.Email); return(customer); }
public ActionResult Create(StoreApp.Library.Customer customer) { if (!ModelState.IsValid) { return(View(customer)); } try { _storeRepo.AddCustomer(customer); return(RedirectToAction("Index")); } catch (Exception ex) { _logger.LogError(ex, "Error While adding customer"); ModelState.AddModelError("", "There was some Error, try again"); return(View()); } }