public static Customer MapToEntity(this CustomerListModels model, Customer entity) { entity.CustomerId = model.CustomerId; entity.CompanyName = model.CompanyName; entity.ContactName = model.ContactTitle; entity.ContactTitle = model.ContactTitle; entity.Address = model.Address; entity.City = model.City; entity.Region = model.Region; entity.Country = model.Country; entity.PostalCode = model.PostalCode; entity.Phone = model.Phone; entity.Fax = model.Fax; entity.User = model.User; entity.Password = model.Password; return(entity); }
public static CustomerListModels MapToModel(this Customer entity, CustomerListModels model) { model.CustomerId = entity.CustomerId; model.CompanyName = entity.CompanyName; model.ContactName = entity.ContactTitle; model.ContactTitle = entity.ContactTitle; model.Address = entity.Address; model.City = entity.City; model.Region = entity.Region; model.Country = entity.Country; model.PostalCode = entity.PostalCode; model.Phone = entity.Phone; model.Fax = entity.Fax; model.User = entity.User; model.Password = entity.Password; return(model); }
public static Customer MapToEntity(this CustomerListModels model) { return(new Customer { CustomerId = model.CustomerId, CompanyName = model.CompanyName, ContactName = model.ContactTitle, ContactTitle = model.ContactTitle, Address = model.Address, City = model.City, Region = model.Region, Country = model.Country, PostalCode = model.PostalCode, Phone = model.Phone, Fax = model.Fax, User = model.User, Password = model.Password, }); }
public CustomerListModels CreateCustomer(CustomerListModels model, out string message) { var ship = _CustomerRepository.getCustomer(model.CustomerId, model.ContactName, model.CompanyName); if (ship != null) { message = Constants.CustomerIsExist; return(null); } var CreateCustomer = _CustomerRepository.Insert(model.MapToEntity()); UnitOfwork.SaveChanges(); if (CreateCustomer == null) { message = Constants.CreateFail; return(null); } message = Constants.CreateSuccess; return(CreateCustomer.MapToModel()); }
public bool UpdateCustomer(CustomerListModels model, out string message) { var CustomerEntity = _CustomerRepository.GetById(model.CustomerId); if (CustomerEntity != null) { var gr = _CustomerRepository.getCustomer(model.CustomerId, model.ContactName, model.CompanyName); if (gr != null) { message = Constants.CustomerIsExist; return(false); } CustomerEntity = model.MapToEntity(CustomerEntity); _CustomerRepository.Update(CustomerEntity); UnitOfwork.SaveChanges(); message = Constants.UpdateSuccess; return(true); } message = Constants.UpdateFail; return(false); }