public bool UpdateCustomer(int id, UpdateCustomerOptions options) { if (options == null || id == 0) { return(false); } var query = context_ .Set <Customer>() .AsQueryable(); if (id > 0) { var customer = query.Where(c => c.CustomerId == id).SingleOrDefault(); customer.FirstName = options.FirstName; customer.LastName = options.LastName; customer.Email = options.Email; customer.IsActive = options.IsActive.Value; if (context_.SaveChanges() > 0) { return(true); } return(false); } else { return(false); } }
public bool UpdateCustomerInfo(int customerId, UpdateCustomerOptions options) { if (options == null) { return(false); } var customer = GetCustomerById(customerId); if (customer == null) { return(false); } if (IsValidEmail(options.Email)) { customer.Email = options.Email; } if (!string.IsNullOrWhiteSpace(options.Phone)) { customer.Phone = options.Phone; } customer.Status = options.Status; return(true); }
public Customer UpdateCustomer(UpdateCustomerOptions options, int customerid) { if (options == null) { return(null); } var customer = SearchCustomers(new SearchCustomerOptions { CustomerId = customerid }).SingleOrDefault(); if (customer != null) { customer.Firstname = options.Firstname; customer.IsActive = options.IsActive; customer.Email = options.Email; } //context_.Add(customer); //context_.SaveChanges(); if (context_.SaveChanges() >= 0) { return(customer); } return(null); }
public bool UpdateCustomer(string CustomerId, UpdateCustomerOptions options) { Customer customer = new Customer(); if (CustomerId != null) { return(false); } if (options == null) { return(false); } if (string.IsNullOrWhiteSpace(options.Email)) { return(false); } if (string.IsNullOrWhiteSpace(options.VatNumber)) { return(false); } customer.Email = options.Email; customer.VatNumber = options.VatNumber; return(true); }
public bool UpdateCustomer(string customerId, UpdateCustomerOptions options) { if (options == null) { return(false); } var customer = GetCustomerById(customerId); if (customer == null) { return(false); } if (!string.IsNullOrWhiteSpace(options.Email)) { customer.Email = options.Email; } if (!string.IsNullOrWhiteSpace(options.FirstName)) { customer.FirstName = options.FirstName; } if (!string.IsNullOrWhiteSpace(options.LastName)) { customer.LastName = options.LastName; } if (options.VatNumber != null) { customer.VatNumber = options.VatNumber; } if (options.Status != null) { customer.Status = options.Status; } return(true); }
public IActionResult Update(int id, [FromBody] UpdateCustomerOptions options) { var result = customerService_.UpdateCustomer(id, options); if (!result) { return(BadRequest()); } return(Ok()); }
public IActionResult UpdateDetails(Guid id, [FromBody] UpdateCustomerOptions options) { var result = _customers.Update(id, options); if (!result.IsSuccessful()) { return(result.ToActionResult()); } return(Ok()); }
public IActionResult UpdateCustomer(int id, [FromBody] UpdateCustomerOptions options) { var result = customers_.UpdateCustomer(id, options); if (!result.Success) { return(StatusCode((int)result.ErrorCode, result.ErrorText)); } return(Ok()); }
public Result <bool> UpdateCustomer(int customerId, UpdateCustomerOptions options) { var result = new Result <bool>(); if (options == null) { result.ErrorCode = StatusCode.BadRequest; result.ErrorText = "Null options"; return(result); } var customer = SearchCustomers(new SearchCustomerOptions { CustomerId = customerId }).SingleOrDefault(); if (customer == null) { result.ErrorCode = StatusCode.NotFound; result.ErrorText = $"Customer with id {customerId} was not found"; return(result); } if (!string.IsNullOrWhiteSpace(options.Email)) { customer.Email = options.Email; } if (options.IsActive != null) { customer.IsActive = options.IsActive.Value; } if (context_.SaveChanges() == 0) { result.ErrorCode = StatusCode.InternalServerError; result.ErrorText = $"Customer could not be updated"; return(result); } result.ErrorCode = StatusCode.OK; result.Data = true; return(result); }
public Customer UpdateCustomer(UpdateCustomerOptions options) { if (options == null) { return(null); } var updateCostumer = context_ .Set <Customer>() .Where(c => c.CustomerId == options.CustomerId) .SingleOrDefault(); if (updateCostumer == null) { return(null); } if (options.Email != null) { updateCostumer.Email = options.Email; } if (options.FirstName != null) { updateCostumer.FirstName = options.FirstName; } if (options.LastName != null) { updateCostumer.LastName = options.LastName; } if (options.Phone != null) { updateCostumer.Phone = options.Phone; } if (options.IsActive != null) { updateCostumer.IsActive = (bool)options.IsActive; } if (context_.SaveChanges() > 0) { return(updateCostumer); } return(null); }
public Result <bool> UpdateCustomer(int customerId, UpdateCustomerOptions options) { var result = new Result <bool>(); if (options == null) { return(Result <bool> .CreateFailed( StatusCode.BadRequest, "Null options")); } var customer = GetCustomerById(customerId).Data; if (customer == null) { return(Result <bool> .CreateFailed( StatusCode.NotFound, $"Customer with id {customerId} was not found")); } if (options.IsActive != null) { customer.IsActive = options.IsActive; } if (!string.IsNullOrWhiteSpace(options.Firstname)) { customer.Firstname = options.Firstname; } if (!string.IsNullOrWhiteSpace(options.LastName)) { customer.Lastname = options.LastName; } if (options.Vatnumber != null) { customer.VatNumber = options.Vatnumber; } if (context_.SaveChanges() == 0) { return(Result <bool> .CreateFailed( StatusCode.InternalServerError, $"Customer could not be updated")); } return(Result <bool> .CreateSuccessful(true)); }
public ApiResult <Customer> Update( Guid customerId, UpdateCustomerOptions options) { if (options == null) { return(new TinyBank.Core.ApiResult <Customer>() { Code = ApiResultCode.NotFound, ErrorText = $"Bad request" }); } var result = GetById(customerId); if (!result.IsSuccessful()) { return(result); } var customer = result.Data; if (customer != null) { customer.Firstname = options.Firstname; customer.Lastname = options.Lastname; customer.VatNumber = options.VatNumber; customer.Type = options.Type; customer.CountryCode = options.CountryCode; _dbContext.SaveChanges(); } else { return(new TinyBank.Core.ApiResult <Customer>() { Code = ApiResultCode.NotFound, ErrorText = $"Customer not found !" }); } return(new ApiResult <Customer>() { Data = customer }); }
/// <summary> /// Update a Customer according the options /// </summary> /// <param name="options"></param> /// <returns></returns> public bool UpdateCustomer(UpdateCustomerOptions options) { var customer = GetCustomerById(options.Id); if (customer == null) { return(false); } if (!string.IsNullOrWhiteSpace(options.Phone)) { customer.Phone = options.Phone; } if (!string.IsNullOrWhiteSpace(options.Email)) { customer.Email = options.Email; } if (!string.IsNullOrWhiteSpace(options.Lastname)) { customer.Lastname = options.Lastname; } if (!string.IsNullOrWhiteSpace(options.Firstname)) { customer.Firstname = options.Firstname; } if (!string.IsNullOrWhiteSpace(options.VatNumber)) { customer.VatNumber = options.VatNumber; } if (options.ChangeActive != null) { customer.Active = !customer.Active; } return(true); }
public Customer UpdateCustomer(UpdateCustomerOptions options) { if (options == null) { return(null); } var customer = SearchCustomers(new SearchCustomerOptions() { CustomerId = options.CustomerId }).SingleOrDefault(); if (customer == null) { return(null); } if (options.FirstName != null) { customer.Firstname = options.FirstName; } if (options.LastName != null) { customer.Lastname = options.LastName; } if (options.Email != null) { customer.Email = options.Email; } if (options.IsActive != null) { customer.IsActive = options.IsActive.Value; } context_.SaveChanges(); return(customer); }
public bool UpdateCustomer( UpdateCustomerOptions options) { if (options == null || options.CustomerId == null) { return(false); } var customer = SearchCustomers(new SearchCustomerOptions() { CustomerId = options.CustomerId }).SingleOrDefault(); if (!string.IsNullOrWhiteSpace(options.Firstname)) { customer.Firstname = options.Firstname; } if (!string.IsNullOrWhiteSpace(options.Lastname)) { customer.Lastname = options.Lastname; } customer.IsActive = options.IsActive; if (!string.IsNullOrWhiteSpace(options.Email)) { customer.Email = options.Email; } if (context.SaveChanges() > 0) { return(true); } return(false); }
public bool UpdateCustomer(int id, UpdateCustomerOptions options) { throw new NotImplementedException(); }
public Customer UpdateCustomer(UpdateCustomerOptions options) { throw new NotImplementedException(); }