Beispiel #1
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 adds new client note in database
        /// </summary>
        /// <param name="clientID">clientID</param>
        /// <param name="introducingBrokerUserID">introducingBrokerUserID</param>
        /// <param name="subject">subject</param>
        /// <param name="note">note</param>
        /// <returns></returns>
        public bool AddNewClientNote(int clientID, int introducingBrokerUserID, string subject, string note)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var clientNoteRepo =
                        new ClientNoteRepository(new EFRepository <ClientNote>(), unitOfWork);

                    ClientNote clientNote = new ClientNote();
                    clientNote.Subject     = subject != String.Empty ? subject : "[No Subject]";
                    clientNote.Note        = note.Replace("\n", "<br>");
                    clientNote.FK_ClientID = clientID;
                    clientNote.FK_IntroducingBrokerUserID = introducingBrokerUserID;
                    clientNote.Timestamp = DateTime.Now;

                    clientNoteRepo.Add(clientNote);
                    clientNoteRepo.Save();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method returns all notes of a particular client under an IB
        /// </summary>
        /// <param name="clientID">clientID</param>
        /// <param name="introducingBrokerUserID">introducingBrokerUserID</param>
        /// <returns></returns>
        public List <ClientNote> GetAllNotesOfClient(int clientID, int introducingBrokerUserID)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var clientNoteRepo =
                        new ClientNoteRepository(new EFRepository <ClientNote>(), unitOfWork);

                    ObjectSet <ClientNote> clientNoteObjSet =
                        ((CurrentDeskClientsEntities)clientNoteRepo.Repository.UnitOfWork.Context).ClientNotes;

                    return(clientNoteObjSet.Where(note => note.FK_ClientID == clientID && note.FK_IntroducingBrokerUserID == introducingBrokerUserID).OrderByDescending(note => note.Timestamp).ToList());
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }