private bool DoCreateCustomer(CustomerViewModel model) { var svc = new CustomerAppSvcGeneric(); var created = svc.Create(model.GetEntity()); return(created.Id > 0); }
public void CreateTestInvalido() { var objCustomer = new Customer { Name = null, ContactName = "Zézim", Cnpj = 32191161000110, IsActive = true, Projects = null }; var srv = new CustomerAppSvcGeneric(); var result = srv.Create(objCustomer); Assert.IsNull(result); //Assert.IsTrue(result.Count() == 0); }
public void CreateTestValido() { var objCustomer = new Customer { Name = "Boteco do Zé - ME", ContactName = "Zézim", Cnpj = 32191161000110, IsActive = true, Projects = null }; var srv = new CustomerAppSvcGeneric(); var result = srv.Create(objCustomer); Assert.IsNotNull(result); Assert.IsTrue(result.Id > 0); }
public IHttpActionResult Create(CustomerViewModel model) { if ( string.IsNullOrEmpty(model.customerName) || string.IsNullOrEmpty(model.contactName) || (model.cnpj == 0 || model.cnpj.ToString().Length < 14) ) { return(BadRequest()); } try { var svc = new CustomerAppSvcGeneric(); var newCustomer = svc.Create(model.GetCustomer()); return(Ok(newCustomer)); } catch (Exception e) { return(InternalServerError(e)); } }