public Model.API.Customer.RegisterResponse CustomerRegister(Model.API.Customer.RegisterRequest registerRequest) { try { if (customerRepository.CheckCustomerExist(registerRequest)) { return(new ParkMark.Model.API.Customer.RegisterResponse() { Status = ParkMark.Model.ResponseStatus.DuplicateObject, EndUserMessage = "Duplicate Email" }); } else { var customer = Mapper.Map <Repository.Customer>(registerRequest); var response = new Model.API.Customer.RegisterResponse(); customer = customerRepository.Add(customer); customerRepository.Save(); response.Email = customer.Email; response.Status = Model.ResponseStatus.Success; response.EndUserMessage = "Register Successful"; return(response); } } catch (Exception ex) { Logger.Error(ex); return(new Model.API.Customer.RegisterResponse() { Status = Model.ResponseStatus.InternalError, EndUserMessage = "An InternalError Happend" }); } }
//public Model.API.Customer.RegisterResponse CustomerRegister(Model.API.Customer.RegisterRequest registerRequest) //{ // context.Customers.Add(new Customer // { // Email = registerRequest.Email, // Password = registerRequest.Password, // RegisterDate = registerRequest.RegisterDate // }); // context.SaveChanges(); // var response = new Model.API.Customer.RegisterResponse() // { // Email = registerRequest.Email, // Status = Model.ResponseStatus.Success // }; // return response; //} public bool CheckCustomerExist(Model.API.Customer.RegisterRequest registerRequest) { if (context.Customers.Any(x => x.Email == registerRequest.Email)) { return(true); } else { return(false); } }
public Model.API.Customer.RegisterResponse Register(Model.API.Customer.RegisterRequest registerRequest) { return(customerLogic.CustomerRegister(registerRequest)); }