Beispiel #1
0
        public MethodResponse GetUsersForWCF()
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                List<User> users = GetUsers();
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = users.Count + "User Listed";
                methodresponse.Object = users;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "GetUsersForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Getting User List";

            }
            return methodresponse;
        }
        public Helper.MethodResponse GetBooksByIdForWCF(int _id)
        {
            MethodResponse methodResponse = new MethodResponse();

            try
            {


                BookDB bookdb = new BookDB();
                methodResponse = bookdb.GetBookByIdForWCF(_id);
                
            }
            catch (Exception exc)
            {
                CustomException customException = new CustomException()
                {
                    Exception = exc,
                    ExceptionTime = DateTime.Now,
                    Parameters = _id.ToString(),
                    HelpLink = "",
                    User = "",
                    MethodName = "GetBooksByIdForWCF"
                };

                //bool IsSaved = customException.SaveException(customException);

                //if (!IsSaved)
                //{
                //    // Mail At
                //}

                methodResponse.Object = null;
                methodResponse.Type = MethodResponse.ResponseType.Error;
                methodResponse.ResultText = "An Error Occurred While Searhing From Service Side";
            }
            return methodResponse;
        }
        public Helper.MethodResponse AddBookForWCF(Data.Model.Book _book)
        {
            MethodResponse methodResponse = new MethodResponse();

            try
            {

                BookDB bookdb = new BookDB();
                methodResponse = bookdb.AddBookForWCF(_book);
                
            }
            catch (Exception exc)
            {
                string serilazedObject = "";
                _book.Serialize(ref serilazedObject);

                CustomException customException = new CustomException()
                {
                    Exception = exc,
                    ExceptionTime = DateTime.Now,
                    Parameters = serilazedObject,
                    HelpLink = "",
                    User = "",
                    MethodName = "AddBookForWCF"
                };

                //bool IsSaved = customException.SaveException(customException);

                //if (!IsSaved)
                //{
                //    // Mail At
                //}

                methodResponse.Object = null;
                methodResponse.Type = MethodResponse.ResponseType.Error;
                methodResponse.ResultText = "An Error Occurred While Adding  From Service Side";
            }
            return methodResponse;
        }
        public Helper.MethodResponse DeleteUserForWCF(int _user)
        {
            MethodResponse methodResponse = new MethodResponse();

            try
            {

                UserDB userdb = new UserDB();
                methodResponse = userdb.DeleteUserForWCF(_user);
            }


            catch (Exception exc)
            {
                CustomException customException = new CustomException()
                {
                    Exception = exc,
                    ExceptionTime = DateTime.Now,
                    Parameters = _user.ToString(),
                    HelpLink = "",
                    User = "",
                    MethodName = "DeleteUserForWCF"
                };

                //bool IsSaved = customException.SaveException(customException);

                //if (!IsSaved)
                //{
                //    // Mail At
                //}

                methodResponse.Object = null;
                methodResponse.Type = MethodResponse.ResponseType.Error;
                methodResponse.ResultText = "";
            }

            return methodResponse;
        }
        public Helper.MethodResponse UpdateUserForWCF(Data.Model.User _user)
        {
            MethodResponse methodResponse = new MethodResponse();

            try
            {


                UserDB userdb = new UserDB();
                methodResponse = userdb.UpdateUserForWCF(_user);


            }
            catch (Exception exc)
            {
                string serilazedObject = "";
                //_book.Serialize(ref serilazedObject);

                CustomException customException = new CustomException()
                {
                    Exception = exc,
                    ExceptionTime = DateTime.Now,
                    Parameters = serilazedObject,
                    HelpLink = "",
                    User = "",
                    MethodName = "UpdateUserForWCF"
                };

                //bool IsSaved = customException.SaveException(customException);

                //if (!IsSaved)
                //{
                //    // Mail At
                //}

                methodResponse.Object = null;
                methodResponse.Type = MethodResponse.ResponseType.Error;
                methodResponse.ResultText = "";
            }
            return methodResponse;
        }
        public Helper.MethodResponse GetReadersForWCF()
        {
            MethodResponse methodResponse = new MethodResponse();

            try
            {


                ReaderDB readerdb = new ReaderDB();
                methodResponse = readerdb.GetReadersForWCF();

            }
            catch (Exception exc)
            {
                CustomException customException = new CustomException()
                {
                    Exception = exc,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "GetReadersForWCF"
                };

                //bool IsSaved = customException.SaveException(customException);

                //if (!IsSaved)
                //{
                //    // Mail At
                //}

                methodResponse.Object = null;
                methodResponse.Type = MethodResponse.ResponseType.Error;
                methodResponse.ResultText = "";
            }
            return methodResponse;
        }
        public Helper.MethodResponse GetBorrowInfosForWCF()
        {
            MethodResponse methodResponse = new MethodResponse();

            try
            {


                BorrowDB borrowdb = new BorrowDB();
                methodResponse = borrowdb.GetBorrowInfosForWCF();

            }
            catch (Exception exc)
            {
                CustomException customException = new CustomException()
                {
                    Exception = exc,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "GetBorrowInfosForWCF"
                };

                //bool IsSaved = customException.SaveException(customException);

                //if (!IsSaved)
                //{
                //    // Mail At
                //}

                methodResponse.Object = null;
                methodResponse.Type = MethodResponse.ResponseType.Error;
                methodResponse.ResultText = "An Error Occurred While Getting A List From Service Side.";
            }
            return methodResponse;
        }
        public MethodResponse GetPublisherByIdForWCF(int _id)
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                Publisher getpublisheridbyid = GetPublisherById(_id);
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = "Publisher  Found That Id Number is" + getpublisheridbyid.PublisherId;
                methodresponse.Object = getpublisheridbyid;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "GetPublisherByIdForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Getting Publisher  By Id";



            }
            return methodresponse;
        }
        public MethodResponse DeletePublisherForWCF(int _publisherId)
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                Publisher deletepublisher = DeletePublisher(_publisherId);
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = "Publisher  Deleted";
                methodresponse.Object = deletepublisher;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "DeletePublisherForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Removing Publisher ";



            }
            return methodresponse;
        }
Beispiel #10
0
        public MethodResponse UpdateUserForWCF(User _user)
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                User user = UpdateUser(_user);
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = "User Updated";
                methodresponse.Object = user;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "UpdateUserForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Updating User";



            }
            return methodresponse;
        }
Beispiel #11
0
        public MethodResponse AddBookForWCF(Book _book)
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                Book lastbook = AddBook(_book);
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = "Book Added";
                methodresponse.Object =lastbook;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "GetBookByIdForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Adding Book";



            }
            return methodresponse;
        }