public AddCustomerViewModel MapCustomerToCustomerVM(Customer lstcust) { AddCustomerViewModel addCustomerViewModel = new AddCustomerViewModel(); AddCustomerViewModel result; if (lstcust != null) { addCustomerViewModel.customerId = lstcust.CustomerId; addCustomerViewModel.CustomerSurName = lstcust.CustomerSurname; addCustomerViewModel.CustomerName = lstcust.CustomerName; addCustomerViewModel.FirmName = lstcust.CustomerFirmname; if (lstcust.CustomerFirmname == null) { addCustomerViewModel.FirmName = ""; } else { addCustomerViewModel.FirmName = lstcust.CustomerFirmname; } addCustomerViewModel.MobileNumber = lstcust.MobileNo.ToString(); addCustomerViewModel.Address = lstcust.Address; addCustomerViewModel.CustomerImageName = lstcust.CustomerImageName; addCustomerViewModel.CustomerImagePath = lstcust.CustomerImagePath; result = addCustomerViewModel; } else { result = null; } return result; }
public int InsertNewCustomer(Customer cust) { this.db.Customers.Add(cust); int result; try { this.db.SaveChanges(); result = 1; } catch { result = 0; } return result; }