Beispiel #1
0
 public IActionResult UpdateEmployee([FromBody] MvEmployeeUpdate employee)
 {
     try
     {
         var updated = _employeeService.UpdateEmployee(employee);
         if (!updated)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #2
0
        public bool UpdateEmployee(MvEmployeeUpdate employee)
        {
            var jsonNew = JsonConvert.SerializeObject(employee);

            using (var conn = _dah.GetConnection())
            {
                using (var cmd = new SqlCommand("SpPersonUpdateTsk", 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);
                }
            }
        }
        public bool UpdateEmployee(MvEmployeeUpdate employeeUpdate)
        {
            using (var connection = _dataAccess.GetConnection())
            {
                var jsonNew = JsonConvert.SerializeObject(employeeUpdate);
                var command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "SpPersonUpdateTsk";
                command.Parameters.Add("@json", SqlDbType.NChar).Value = jsonNew;
                command.CommandTimeout = _commandTimeout;

                int rows = command.ExecuteNonQuery();

                if (rows > 0)
                {
                    return(true);
                }
                return(false);
            }
        }