Ejemplo n.º 1
0
        public void CreateBookLender(BookLender bookLender)
        {
            try
            {
                using (var trans = _iAdoNetContext.CreateTransaction())
                {
                    try
                    {
                        using (var cmd = _iAdoNetContext.CreateCommand(trans))
                        {
                            _iBookRepositoryQuery.CreateBookLender(bookLender, cmd);

                            trans.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        //TODO: Log this the exception information along with the method details to the database for Error tracing
                        //Allowing the exception be rethrown so that LOG4NET can log there is a problem on the api end point
                        trans.Rollback();
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                //TODO: Log this the exception information along with the method details to the database for Error tracing
                //Allowing the exception be rethrown so that LOG4NET can log there is a problem on the api end point
                throw ex;
            }
        }
Ejemplo n.º 2
0
        //Broacasts to all clients
        public void CheckOutBook(BookLender bookLender)
        {
            try
            {
                BookBorrowResult bookBorrowResult = new BookBorrowResult();

                if (bookLender == null ||
                    string.IsNullOrWhiteSpace(bookLender.BookISBN) ||
                    string.IsNullOrWhiteSpace(bookLender.FriendName) ||
                    string.IsNullOrWhiteSpace(bookLender.BorrowDate))
                {
                    bookBorrowResult.Status = "Validation Error";
                }
                else
                {
                    _iBookService.CreateBookLender(bookLender);
                    bookBorrowResult.Status   = "Success";
                    bookBorrowResult.BookISBN = bookLender.BookISBN;
                }

                Clients.All.CheckOutBookResult(bookBorrowResult);
            }
            catch (Exception ex)
            {
                //Log this error ex

                //This is done to allow the exception to flow to client for error notification
                throw new HubException();
            }
        }
Ejemplo n.º 3
0
        public JsonResult CreateBookLender(BookLender bookLender)
        {
            _iBookService.CreateBookLender(bookLender);

            return(new JsonResult()
            {
                Data = string.Format("{0} was successfully saved.", bookLender.FriendName)
            });
        }
Ejemplo n.º 4
0
 public void CreateBookLender(BookLender bookLender)
 {
     try
     {
         _bookRepository.CreateBookLender(bookLender);
     }
     catch (Exception ex)
     {
         //TODO: Log this the exception information along with the method details to the database for Error tracing
         //Allowing the exception be rethrown so that LOG4NET can log there is a problem on the api end point
         throw ex;
     }
 }
Ejemplo n.º 5
0
        public void CreateBookLender(BookLender bookLender, IDbCommand command)
        {
            //This proc will go find the book id by the isbn number and then use that when creating a new lender
            command.CommandText = @"exec [dbo].[CreateBookLender]
                                        @LenderName
                                       ,@BookISBN
                                       ,@DateLent
                                       ,@Comment";

            var parameter = command.CreateParameter();

            parameter.ParameterName = "@LenderName";
            parameter.DbType        = DbType.String;
            parameter.Value         = bookLender.FriendName;
            command.Parameters.Add(parameter);

            parameter = command.CreateParameter();
            parameter.ParameterName = "@BookISBN";
            parameter.DbType        = DbType.String;
            parameter.Value         = bookLender.BookISBN;
            command.Parameters.Add(parameter);

            parameter = command.CreateParameter();
            parameter.ParameterName = "@DateLent";
            parameter.DbType        = DbType.Date;
            parameter.Value         = bookLender.BorrowedDateTime;
            command.Parameters.Add(parameter);

            parameter = command.CreateParameter();
            parameter.ParameterName = "@Comment";
            parameter.DbType        = DbType.String;
            parameter.Value         = bookLender.Comments;
            command.Parameters.Add(parameter);

            command.ExecuteNonQuery();
        }