示例#1
0
        public async Task <ActionResult> Delete(int user_id, int review_id)
        {
            try
            {
                // Searching for record inn the Review table
                var response = await _repository.GetById(user_id, review_id);

                // Deleting record from Review table
                await _repository.DeleteById(user_id, review_id);

                string format = "Review record with key=({0},{1}) deleted succesfully\n";
                return(Ok(string.Format(format, user_id, review_id)));
            }
            catch (Npgsql.PostgresException ex)
            {
                // Postgres threw an exception
                return(BadRequest(ex.Message.ToString()));
            }
            catch
            {
                // Unknown error
                return(BadRequest("Error: Review record could not be deleted\n"));
            }
        }