/// <summary> /// Gets the Top 1000 customers including their types navigation properties /// </summary> /// <returns></returns> // POST api/customers/GetTop1000 public IHttpActionResult BulkInserOfRandomCustomers([FromBody] BulkInsertInputDto bulkInsertInputDto) { try { if (ModelState.IsValid) { var result = CustomersBusinessManager .BulkInsertOfRandomCustomers(bulkInsertInputDto.BulkNumber); return(Ok(result)); } else { return(BadRequest("The number must be equal or greater than 100.")); } } catch (Exception e) { throw; } }
/// <summary> /// Gets the Top 1000 customers including their types navigation properties /// </summary> /// <returns></returns> // Post customers/GetTop1000 public ActionResult BulkInsertOfRandomCustomersForm(BulkInsertOfRandomCustomersFormVM bulkInsertOfRandomCustomersFormVM) { try { if (ModelState.IsValid) { BulkInsertInputDto bulkInsertInputDto = new BulkInsertInputDto { BulkNumber = bulkInsertOfRandomCustomersFormVM.BulkNumber }; var result = CustomersBusinessManager .BulkInsertOfRandomCustomers(bulkInsertInputDto.BulkNumber); bulkInsertOfRandomCustomersFormVM.ResultMessage = result.Success ? bulkInsertOfRandomCustomersFormVM.BulkNumber.ToString() + " Customers were created successfully." : "Customers creation failed."; bulkInsertOfRandomCustomersFormVM.IsFailed = result.Success ? false : true; return(View("BulkInsertOfRandomCustomersPage", bulkInsertOfRandomCustomersFormVM)); } else { return(View()); } } catch (Exception e) { bulkInsertOfRandomCustomersFormVM.ResultMessage = "Customers creation failed: " + e.Message.Replace(" See the inner exception for details.", ""); bulkInsertOfRandomCustomersFormVM.IsFailed = true; return(View("BulkInserOfRandomCustomersPage", bulkInsertOfRandomCustomersFormVM)); } }