예제 #1
0
        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);
        }
예제 #2
0
 public IActionResult CreateCustomer([FromBody] CusCustomer customer)
 {
     if (ModelState.IsValid)
     {
         var result = _repository.CreateCustomer(customer);
         return(result);
     }
     else
     {
         return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest));
     }
 }
예제 #3
0
 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));
     }
 }
예제 #4
0
 public string CreateCustomer(CusCustomer customer)
 {
     try
     {
         _dbContext.Customer.Add(customer);
         _dbContext.SaveChanges();
         return(HttpStatusCode.Created.ToString());
     }
     catch (Exception exp)
     {
         throw exp;
     }
 }
예제 #5
0
 public IActionResult CreateCustomer(CusCustomer customer)
 {
     try
     {
         _dbContext.Customer.Add(customer);
         _dbContext.SaveChanges();
         return(new HttpStatusCodeResult((int)HttpStatusCode.Created));
     }
     catch (Exception exp)
     {
         throw exp;
     }
 }
예제 #6
0
        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);
        }
예제 #7
0
 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;
     }
 }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
 public string CreateCustomer(CusCustomer customer)
 {
     throw new NotImplementedException();
 }
예제 #11
0
 public string UpdateCustomer(long custKey, CusCustomer customer)
 {
     throw new NotImplementedException();
 }
예제 #12
0
        public IEnumerable <CusCustomer> GetCustomerDetailsByAll(string searchOperator, [FromBody] CusCustomer customer)
        {
            var customerDetails = _repository.GetCustomerByAll(customer, searchOperator);

            return(customerDetails);
        }