public async Task AddSupplier(CarSupplier supplier) { if (supplier.CarIds == null) { supplier.CarIds = new List <string>(); } await _collection.InsertOneAsync(supplier); }
public async Task UpdateSupplier(string supplierId, CarSupplier supplier) { var updateFields = Builders <CarSupplier> .Update .Set(supp => supp.Name, supplier.Name) .Set(supp => supp.Website, supplier.Website) .Set(supp => supp.ContactName, supplier.ContactName) .Set(supp => supp.ContactEmail, supplier.ContactEmail) .Set(supp => supp.ContactPhoneNumber, supplier.ContactPhoneNumber); await _collection.FindOneAndUpdateAsync(supplier => supplier.Id == supplierId, updateFields); }
public async Task <IActionResult> UpdateSupplier(string supplierId, [FromForm] CarSupplier supplier) { await _carSupplierRepo.UpdateSupplier(supplierId, supplier); return(Ok()); }
public async Task <IActionResult> AddSupplier([FromForm] CarSupplier supplier) { await _carSupplierRepo.AddSupplier(supplier); return(Ok()); }