public async Task <GetSupplierDto> UpdateSupplierAsync(long id, EditSupplierDto supplierDto) { var supplier = await GetSupplierId(id); await CheckSupplierAsync(id, supplierDto.Name); supplier = _mapper.Map(supplierDto, supplier); await _supplier.UpdateSupplierAsync(supplier); return(_mapper.Map <GetSupplierDto>(supplier)); }
public async Task <IActionResult> Edit([FromRoute, Required] int supplierId, [FromBody] EditSupplierDto dto) { try { return(await _mediator.Send(new EditSupplierCommand { SupplierId = supplierId, Body = dto })); } catch (Exception ex) { _logger.LogError(ex, "Error in {0}", HttpContext.Request.Path); return(BadRequest(ErrorMessages.InternalExceptionModel)); } }
public EditSupplierDtoValidatorFixture() { Validator = new EditSupplierDtoValidator(); Model = new EditSupplierDto { Name = "Test Supplier Pvt Ltd", Address1 = "#03-81, BLK 227", Address2 = "Bishan Street 23", City = "Bishan", Country = "Singapore", Telephone1 = "+94666553456", Telephone2 = "+94888775678", Fax = "+94666448856", Email = "*****@*****.**", ContactPerson = "James" }; }
public async Task <IActionResult> PutSuppliers([FromRoute] int id, [FromBody] EditSupplierDto editSupplierDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != editSupplierDto.SupplierId) { return(BadRequest()); } var preSupplier = _mapper.Map <Suppliers> (editSupplierDto); _repo.Update(preSupplier); await _repo.SaveAsync(preSupplier); return(NoContent()); }
public SupplierRepositoryFixture() { MockSupplierService = new Mock <ISupplierService>(); Suppliers = new List <Supplier> { new Supplier { Id = 1, Name = "ABC Pvt Ltd", Address1 = "American Mission School Road", Address2 = "Madduvil South", City = "Chavakachcheri", Country = "Sri Lanka", Telephone1 = "0765554345", Telephone2 = "0766554567", Fax = "", Email = "*****@*****.**", ContactPerson = "James" }, new Supplier { Id = 2, Name = "VBT Pvt Ltd", Address1 = "VBT Road", Address2 = "VBTt", City = "Jaffna", Country = "Sri Lanka", Telephone1 = "0777113644", Telephone2 = "", Fax = "", Email = "*****@*****.**", ContactPerson = "James" } }; CollectionEnvelop = new CollectionEnvelop <Supplier> { Items = Suppliers, ItemsPerPage = 10, TotalItems = 2, }; CreateSupplierDto = new CreateSupplierDto { Name = "Jaffna Supplier Pvt Ltd", Address1 = "Kandy Road", Address2 = "Kaithady", City = "Jaffna", Country = "Sri Lanka", Telephone1 = "+94666553456", Telephone2 = "+94888775678", Fax = "+94666448856", Email = "*****@*****.**", ContactPerson = "Aathavan" }; CreatedNewSupplier = new Supplier { Id = 3, Name = CreateSupplierDto.Name, Address1 = CreateSupplierDto.Address1, Address2 = CreateSupplierDto.Address2, City = CreateSupplierDto.City, Country = CreateSupplierDto.Country, Telephone1 = CreateSupplierDto.Telephone1, Telephone2 = CreateSupplierDto.Telephone2, Fax = CreateSupplierDto.Fax, Email = CreateSupplierDto.Email, ContactPerson = CreateSupplierDto.ContactPerson }; EditSupplierDto = new EditSupplierDto { Name = "VBT Pvt Ltd", Address1 = "#03-46, Blk 687", Address2 = "Hindu College Road", City = "Jaffna", Country = "Sri Lanka", Telephone1 = "0777113644", Telephone2 = "0777113644", Fax = "0777113644", Email = "*****@*****.**", ContactPerson = "James" }; }
public async Task <IActionResult> UpdateSupplier(long id, EditSupplierDto supplierDto) { var result = await _repository.UpdateSupplierAsync(id, supplierDto); return(Ok(result)); }
public SupplierControllerFixture() { ApiVersion = new ApiVersion(1, 0); MockSupplierRepository = new Mock <ISupplierRepository>(); Suppliers = new List <GetSupplierDto> { new GetSupplierDto { Id = 1, Name = "Test Supplier Pvt Ltd", Address1 = "#03-81, BLK 227", Address2 = "Bishan Street 23", City = "Bishan", Country = "Singapore", Telephone1 = "+94666553456", Telephone2 = "+94888775678", Fax = "+94666448856", Email = "*****@*****.**", ContactPerson = "James" }, }; SupplierEnvelop = new SupplierEnvelop { SupplierCount = 1, Suppliers = Suppliers, ItemsPerPage = 10, TotalPages = 1 }; ValidCreateSupplierDto = new CreateSupplierDto { Name = "Jaffna Supplier Pvt Ltd", Address1 = "Kandy Road", Address2 = "Kaithady", City = "Jaffna", Country = "Sri Lanka", Telephone1 = "+94666553456", Telephone2 = "+94888775678", Fax = "+94666448856", Email = "*****@*****.**", ContactPerson = "Aathavan" }; CreateSupplierDtoResult = new GetSupplierDto { Id = 2, Name = "Jaffna Supplier Pvt Ltd", Address1 = "Kandy Road", Address2 = "Kaithady", City = "Jaffna", Country = "Sri Lanka", Telephone1 = "+94666553456", Telephone2 = "+94888775678", Fax = "+94666448856", Email = "*****@*****.**", ContactPerson = "Aathavan" }; ValidEditSupplierDto = new EditSupplierDto { Name = "Colombo Supplier Pvt Ltd", Address1 = "#06-02, Perea Lane", Address2 = "Wellawatta", City = "Colombo", Country = "Sri Lanka" }; EditSupplierDtoResult = new GetSupplierDto { Id = 1, Name = "Colombo Supplier Pvt Ltd", Address1 = "#06-02, Perea Lane", Address2 = "Wellawatta", City = "Colombo", Country = "Sri Lanka", Telephone1 = "+94666553456", Telephone2 = "+94888775678", Fax = "+94666448856", Email = "*****@*****.**", ContactPerson = "James" }; }