예제 #1
0
 public IActionResult UpdateEmployee([FromBody] MvPersonUpdate personUpdate)
 {
     try
     {
         var updated = _personService.UpdatePerson(personUpdate);
         if (!updated)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public bool UpdatePerson(MvPersonUpdate personUpdate)
        {
            using (var connection = _dah.GetConnection())
            {
                var jsonNew = JsonConvert.SerializeObject(personUpdate);
                var command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "SpUpdatePersonTsk";
                command.Parameters.Add("@json", SqlDbType.NChar).Value = jsonNew;
                command.CommandTimeout = _comdTimeout;

                int rows = command.ExecuteNonQuery();

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