public async Task ShouldCreateSupplier(string cpnj, string corporateName, string tradingName, string telephone, string email) { var adressModel = new Address("Rua amazonas", "bairro joaonese", "marilandia", "SC", 102); var userId = Guid.NewGuid(); var model = new SupplierRequestModel() { cpnj = cpnj, CorporateName = corporateName, TradingName = tradingName, Telephone = telephone, Address = adressModel, Email = email }; await _supplierService.Create(model); await _supplierRepository .Received(1) .Create(Arg.Is <Supplier>(x => x.TradingName == tradingName && x.CorporateName == corporateName && x.Telephone.ToString() == telephone && x.Email.ToString() == email && x.cpnj == cpnj && x.Address == adressModel )); }
public HttpResponseMessage Create(HttpRequestMessage request, SupplierViewModel model) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadGateway, ModelState); } else { try { Supplier objDB = supplierService.GetSingleByName(model.SupplierName); if (objDB != null) { string msgError = string.Format("Nhà cung cấp {0} đã tồn tại. Vui lòng kiểm tra lại!", model.SupplierName); response = request.CreateResponse(HttpStatusCode.BadGateway, msgError); } Supplier objNew = new Supplier(); objNew.UpdateSupplier(model); supplierService.Create(objNew); supplierService.SaveChanges(); response = request.CreateResponse(HttpStatusCode.OK, objNew); return response; } catch (Exception ex) { response = request.CreateResponse(HttpStatusCode.NotFound, ex.Message); } } return response; })); }
public async Task <Supplier> Create(Supplier supplier) { var supplierCreate = await _supplierService.Create(supplier); //_logger.LogTrace($"GetAll methods executed with paramters : {category} and response : {categoryPost} "); return(supplierCreate); }
// GET: Suppliers/Create public ActionResult Create() { SupplierDto supplier = SupplierService.Create(); supplier.AllGroups = GroupService.getAllGroups(); return(View(supplier)); }
public ActionResult CreateSupplier(SupplierViewModel supplierViewModel) { var mapper = new MapperConfiguration(cfg => cfg.CreateMap <SupplierViewModel, Supplier>()).CreateMapper(); var supplier = mapper.Map <Supplier>(supplierViewModel); _supplierService.Create(supplier); return(RedirectToAction("Index")); }
public IActionResult Create(SupplierDto supplierDto) { if (ModelState.IsValid) { var reulst = _supplierService.Create(supplierDto); return(RedirectToAction("Index")); } return(View()); }
public async Task <ActionResult <SupplierResource> > Create(SaveSupplierResource supplierResource) { var supplier = mapper.Map <SaveSupplierResource, Supplier>(supplierResource); var newSupplier = await service.Create(supplier); var returnSupplier = mapper.Map <Supplier, SupplierResource>(newSupplier); return(CreatedAtAction(nameof(GetAll), new { id = supplier.Id }, returnSupplier)); }
// POST: api/Suppliers public HttpResponseMessage Post(SupplierVM supplierVM) { if (supplierService.Create(supplierVM) == 0) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } //return supplier.Create(supplierVM); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public IActionResult Post(SupplierVM supplierVM) { var push = _supplierService.Create(supplierVM); if (push > 0) { return(Ok("Successfully Added!")); } return(BadRequest("Added Row Failed!")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _service.Create(Supplier); return(RedirectToPage("./Index")); }
// POST: api/Suppliers public HttpResponseMessage Post(SupplierVM supplierVM) { var inserted = _supplierService.Create(supplierVM); if (inserted > 0) { new HttpResponseMessage(HttpStatusCode.BadRequest); } return(Request.CreateResponse(HttpStatusCode.OK, inserted)); }
public IActionResult Create(SupplierViewModel supplierViewModel) { var data = _supplierService.Create(supplierViewModel); if (data > 0) { return(Ok(data)); } return(BadRequest("Bad Request")); }
public IActionResult AddSupplier([FromForm] ViewModels.Supplier supplier) { if (_supplierService.CheckIfExists(supplier.Cnpj)) { return(Ok("O fornecedor já foi cadastrado anteriormente.")); } //TODO: pegar da sessão supplier.CreatedBy = new Guid("7BF0E9EB-4D12-4070-98FC-06DBDB703BE0"); _supplierService.Create(supplier); return(Ok()); }
public async Task <ActionResult <Data.Models.Supplier> > PostSupplier(Data.Models.Supplier supplier) { if (supplier == null) { return(BadRequest()); } supplier.Slug = Slug.Generate(supplier.CompanyName); await _supplierService.Create(supplier); return(CreatedAtAction("GetSupplier", new { id = supplier.Id }, supplier)); }
public void Should_create_supplier() { var supplier = GetSupplierExample(); _companyService.Read(supplier.CompanyId).Returns(GetCompanyExample()); _supplierService.Create(supplier); _supplierRepository.Received(1).Create(Arg.Is <Supplier>(s => s.Name == "Ronaldo" && s.Company.TradingName == "Mercado Chicão" && s.Document.ToString() == "086.263.709-03" && s.RG == "623267" && s.RegisterTime.Date == DateTime.Now.Date && s.BirthDate == new DateTime(2001, 12, 7) && s.Telephones[0] == supplier.Telephones[0])); }
public async Task <ActionResult <CreatedResult> > PostSupplier([FromBody] Supplier supplier) { Supplier result; try { result = _supplierservice.Create(supplier); } catch (Exception e) { return(BadRequest()); } Supplier updatedResult = result.Clone(0, DateTime.Now, DateTime.Now); return(CreatedAtAction(nameof(PostSupplier), new { id = updatedResult.id }, updatedResult)); }
public async Task <ActionResult <SupplierDTO> > Create(SupplierDTO supplierDTO) { if (!ModelState.IsValid) { return(BadRequest()); } var result = await _supplierService.Create(supplierDTO); if (!result) { return(BadRequest()); } return(Created("api/fornecedores", supplierDTO)); }
public async Task <IActionResult> Create(SupplierCreateRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _supplierService.Create(request); if (result == 0) { return(BadRequest()); } var supplier = await _supplierService.GetById(result); return(CreatedAtAction(nameof(GetById), new { id = result }, supplier)); }
// POST api/suppliers/id public IHttpActionResult PostSupplier([FromBody] SupplierModelView supplier) { if (!ModelState.IsValid || supplier == null) { return(BadRequest()); } var model = new SupplierDTO { CompanyName = supplier.CompanyName, Products = mapper.Map <ICollection <ProductModelView>, ICollection <ProductDTO> >(supplier.Products) }; supplierService.Create(model); return(Ok(new { Message = $"The new supplier {supplier.CompanyName} has created" })); }
public ActionResult <Supplier> Post([FromBody] Supplier Supplier) { if (string.IsNullOrEmpty(Supplier.Name)) { return(BadRequest("City required.")); } else if (string.IsNullOrEmpty(Supplier.Phone)) { return(BadRequest("Country required.")); } else if (string.IsNullOrEmpty(Supplier.Email)) { return(BadRequest("PostalCode required.")); } _SupplierService.Create(Supplier); return(Ok("Address successfully created.")); }
public async Task <IActionResult> Create([FromBody] SupplierCreate request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var resultId = await _supplierService.Create(request); if (!resultId.IsSuccessed) { return(BadRequest(resultId)); } var result = await _supplierService.GetById(resultId.ResultObj); return(Ok(result)); }
public async Task <IActionResult> CreateSupplier([FromBody] SupplierDto data) { const string loggerHeader = "CreateSupplier -"; _logService.Info($"{loggerHeader} Start"); var result = new ApiJsonResult(); try { var userLogin = await _userService.GetCurrentUserLogin(HttpContext); _logService.Info($"{loggerHeader} Create with tenantId {userLogin.TenantId}"); result = await _supplierService.Create(userLogin.TenantId, data); } catch (Exception ex) { _logService.Error($"{loggerHeader} Throw error {ex.Message}"); result.Code = CodeModel.Fail; result.Message = ex.Message; } return(Ok(result)); }
public ActionResult AddSupplier(SupplierModel model) { try { if (ModelState.IsValid) { var dataModel = new Supplier() { SupplierName = model.SupplierName, NotificationURL = model.NotificationUrl }; _supplierService.Create(dataModel); return(RedirectToAction("Index")); } } catch (DataException /*dex*/) { // log dex ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(model)); }
public ActionResult <SupplierDto> PostSupplier(SupplierCreateDto supplierCreateDto) { return(new ActionResult <SupplierDto>(_supplierService.Create(supplierCreateDto))); }
public IHttpActionResult Post(Supplier Supplier) { var newSupplier = SupplierService.Create(Supplier); return(Ok(Supplier)); }
public SupplierDTO Create(SupplierCreateDTO createModel) { return(_supplierService.Create(createModel)); }
public async Task <IActionResult> Create([FromBody] SupplierRequestModel request) { await _supplierService.Create(request); return(Accepted()); }
public async Task <IActionResult> CreateAsync([FromForm] CreateSupplierDTO dto) { await _SupplierService.Create(dto); return(Ok(GetRespons())); }
public SupplierEntity Create([FromBody] SupplierEntity SupplierEntity) { return(SupplierService.Create(EmployeeEntity, SupplierEntity)); }
public IActionResult Create([FromBody] Supplier supplier) { _supplierService.Create(supplier); return(Accepted()); }