public string AddCustomer(MvCustomer customer)
        {
            string json = string.Empty;

            ActionProcedures.SpCustomerIns(JsonConvert.SerializeObject(customer, new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            }), ref json);
            return(json);
        }
 public IActionResult customerUpdate([FromBody] MvCustomer customer)
 {
     try
     {
         var data = _customerService.updateCustomer(customer);
         return(Ok(data));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
 public IActionResult EditCustomer([FromBody] MvCustomer customer)
 {
     try
     {
         customerService.EditCustomer(customer);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemple #4
0
 public IActionResult Customer([FromBody] MvCustomer customer)
 {
     try
     {
         string json = customerService.AddCustomer(customer);
         return(Ok(json));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public dynamic UpdateCustomer(MvCustomer customer)
        {
            var json = JsonConvert.SerializeObject(customer);

            using (var sql = _dah.GetConnection())
            {
                using (SqlCommand command = new SqlCommand("SpCustomerUpd", sql))
                {
                    command.CommandType = (System.Data.CommandType.StoredProcedure);;
                    command.Parameters.Add(new SqlParameter("@json", json));
                    command.ExecuteNonQuery();
                    return(customer);
                }
            }
        }
 public IActionResult AddCustomer([FromBody] MvCustomer customer)
 {
     try
     {
         var added = _customerService.AddPerson(customer);
         if (!added)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #7
0
 public IActionResult CustomerUpdate([FromBody] MvCustomer customer)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     try
     {
         var data = _customerService.UpdateCustomer(customer);
         return(Ok(data));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #8
0
        public bool AddCustomer(MvCustomer customer)
        {
            var jsonNew = JsonConvert.SerializeObject(customer);

            using (var conn = _dah.GetConnection())
            {
                using (var cmd = new SqlCommand("SpCustomerInsertTsk", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@Json", SqlDbType.NChar).Value = jsonNew;
                    cmd.CommandTimeout = int.Parse(_commandTimeout);
                    int rows = cmd.ExecuteNonQuery();
                    if (rows > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
        }
Exemple #9
0
        public bool AddPerson(MvCustomer customer)
        {
            using (var connection = _dah.GetConnection())
            {
                var jsonNew = JsonConvert.SerializeObject(customer);
                var command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "SpCustomerInsertTsk";
                command.Parameters.Add("@json", SqlDbType.NChar).Value = jsonNew;
                command.CommandTimeout = _comdTimeout;

                int rows = command.ExecuteNonQuery();

                if (rows > 0)
                {
                    return(true);
                }
                return(false);
            }
        }
Exemple #10
0
 public IActionResult AddCustomer([FromBody] MvCustomer customer)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     try
     {
         var added = _customerService.AddCustomer(customer);
         if (!added)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch (Exception)
     {
         throw;
     }
 }
 public void EditCustomer(MvCustomer customer)
 {
     ActionProcedures.SpCustomerUpd(JsonConvert.SerializeObject(customer, new JsonSerializerSettings {
         ContractResolver = new CamelCasePropertyNamesContractResolver()
     }));
 }