Beispiel #1
0
        /// <summary>
        /// Function to make entry in database for uploaded document
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="docID">docID</param>
        /// <param name="docName">docName</param>
        /// <returns></returns>
        public bool UploadDocument(int userID, int docID, string docName)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userDocRepo =
                        new UserDocumentRepository(new EFRepository <UserDocument>(), unitOfWork);

                    UserDocument doc = new UserDocument();
                    doc.UserDocumentName = docName;
                    doc.FK_DocumentID    = docID;
                    doc.Status           = "Pending";
                    doc.FK_UserID        = userID;
                    doc.IsDeleted        = false;

                    userDocRepo.Add(doc);
                    userDocRepo.Save();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method deletes user document by setting IsDeleted column to true
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="docID">docID</param>
        /// <returns></returns>
        public string ClearUserDocument(int userID, int docID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userDocRepo =
                        new UserDocumentRepository(new EFRepository <UserDocument>(), unitOfWork);

                    ObjectSet <UserDocument> userDocObjSet =
                        ((CurrentDeskClientsEntities)userDocRepo.Repository.UnitOfWork.Context).UserDocuments;

                    var userDoc = userDocObjSet.Where(doc => doc.FK_UserID == userID && doc.FK_DocumentID == docID && doc.IsDeleted == false).FirstOrDefault();

                    if (userDoc != null)
                    {
                        userDoc.IsDeleted = true;
                        userDocRepo.Save();
                        return(userDoc.UserDocumentName);
                    }

                    return(String.Empty);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Beispiel #3
0
        // Add your own data access methods here.  If you wish to
        // expose your public method to a WCF service, marked them with
        // the attribute [NCPublish], and another T4 template will generate your service contract

        /// <summary>
        /// This method returns user document details
        /// </summary>
        /// <param name="userID">userID</param>
        /// <param name="docID">docID</param>
        /// <returns></returns>
        public UserDocument GetUserDocumentDetails(int userID, int docID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var userDocRepo =
                        new UserDocumentRepository(new EFRepository <UserDocument>(), unitOfWork);

                    ObjectSet <UserDocument> userDocObjSet =
                        ((CurrentDeskClientsEntities)userDocRepo.Repository.UnitOfWork.Context).UserDocuments;

                    return(userDocObjSet.Include("Document").Where(doc => doc.FK_UserID == userID && doc.FK_DocumentID == docID && doc.IsDeleted == false).FirstOrDefault());
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }