public IActionResult CreateCustomer([FromBody] CustomerForCreationDto customerInfo) { var customerError = "Please look at your data and make sure it's not empty, incorrect, or has values that are the same!"; Customer customer = new Customer(); if (customerInfo == null) { return(BadRequest(customerError)); } if (customerInfo.Name == customerInfo.Adress || customerInfo.Name == customerInfo.MobileNr || customerInfo.MobileNr == customerInfo.Adress) { return(BadRequest(customerError)); } // Convert CustomerForCreationDto to Customer entity customer.Adress = customerInfo.Adress; if (customer.Adress.Length > 50) { return(StatusCode(500, "Your adress is too long. Please make sure it's less than 50 characters!")); } customer.Name = customerInfo.Name; if (customer.Name.Length > 50) { return(StatusCode(500, "Your name is too long. Please ensure it's less than 50 characters long!")); } customer.CreatedAtDate = DateTime.Now; customer.UpdatedAtDate = customer.CreatedAtDate; _customerInfoRepository.AddCustomer(customer); if (!_customerInfoRepository.Save()) { return(StatusCode(500, "A problem happened while handling your request.")); } return(Ok(customer)); }