public IEnumerable <CusCustomer> GetCustomerByAll(CusCustomer _objcust, string searchOperator) { var customer = new List <CusCustomer>(); try { if (searchOperator.ToUpper() == "AND") { if (_objcust.CustomerKey != 0 && !string.IsNullOrEmpty(_objcust.FirstName)) { customer = (from c in _dbContext.Customer where Convert.ToString(c.CustomerKey).StartsWith(Convert.ToString(_objcust.CustomerKey)) && (c.FirstName.StartsWith(_objcust.FirstName)) select c).ToList(); } } else if (searchOperator.ToUpper() == "OR") { if (_objcust.CustomerKey != 0 || !string.IsNullOrEmpty(_objcust.FirstName)) { customer = (from c in _dbContext.Customer where Convert.ToString(c.CustomerKey).StartsWith(Convert.ToString(_objcust.CustomerKey)) || (c.FirstName.StartsWith(_objcust.FirstName)) select c).ToList(); } } } catch (Exception exp) { throw exp; } return(customer); }
public IActionResult CreateCustomer([FromBody] CusCustomer customer) { if (ModelState.IsValid) { var result = _repository.CreateCustomer(customer); return(result); } else { return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest)); } }
public IActionResult UpdateCustomerDetails(long customerKey, [FromBody] CusCustomer customer) { if (ModelState.IsValid) { var result = _repository.UpdateCustomer(customerKey, customer); return(result); } else { return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest)); } }
public string CreateCustomer(CusCustomer customer) { try { _dbContext.Customer.Add(customer); _dbContext.SaveChanges(); return(HttpStatusCode.Created.ToString()); } catch (Exception exp) { throw exp; } }
public IActionResult CreateCustomer(CusCustomer customer) { try { _dbContext.Customer.Add(customer); _dbContext.SaveChanges(); return(new HttpStatusCodeResult((int)HttpStatusCode.Created)); } catch (Exception exp) { throw exp; } }
public CusCustomer GetCustomerById(string Id) { CusCustomer customer = new CusCustomer(); try { customer = _dbContext.Customer.Where(c => c.Id == Id).FirstOrDefault(); } catch (Exception exp) { throw exp; } return(customer); }
public string UpdateCustomer(long custKey, CusCustomer customer) { try { var cust = _dbContext.Customer.Where(p => p.CustomerKey == custKey).First(); if (cust != null) { cust.FirstName = customer.FirstName; cust.LastName = customer.LastName; cust.Created = customer.Created; cust.CreatedBy = customer.CreatedBy; cust.Modified = customer.Modified; cust.ModifiedBy = customer.ModifiedBy; _dbContext.SaveChanges(); } return(HttpStatusCode.OK.ToString()); } catch (Exception exp) { throw exp; } }
public IEnumerable <CusCustomer> GetCustomerByAll(CusCustomer _objcust) { IEnumerable <CusCustomer> customerList = null; try { using (var client = GetHttpClient()) { var response = client.GetAsync(this.BaseUri + string.Format(CUSTOMER_BY_ALL, _objcust)).Result; if (response.IsSuccessStatusCode) { var result = response.Content.ReadAsStringAsync().Result; customerList = JsonConvert.DeserializeObject <IEnumerable <CusCustomer> >(result); } } } catch { return(null); } return(customerList); }
public CusCustomer GetCustomerById(string Id) { CusCustomer customer = null; try { using (var client = GetHttpClient()) { var response = client.GetAsync(this.BaseUri + string.Format(CUSTOMER_BY_ID, Id)).Result; if (response.IsSuccessStatusCode) { var result = response.Content.ReadAsStringAsync().Result; customer = JsonConvert.DeserializeObject <CusCustomer>(result); } } } catch (Exception ex) { throw ex; } return(customer); }
public string CreateCustomer(CusCustomer customer) { throw new NotImplementedException(); }
public string UpdateCustomer(long custKey, CusCustomer customer) { throw new NotImplementedException(); }
public IEnumerable <CusCustomer> GetCustomerDetailsByAll(string searchOperator, [FromBody] CusCustomer customer) { var customerDetails = _repository.GetCustomerByAll(customer, searchOperator); return(customerDetails); }