示例#1
0
        public JsonResult Add(int clientId, string text)
        {
            try
            {
                var userId = User.Identity.GetUserId();
                var client = db.Clients.Find(clientId);
                var note   = new ClientNote()
                {
                    Date     = DateTime.Now,
                    Text     = text,
                    ClientId = clientId,
                    UserId   = userId
                };
                db.ClientNotes.Add(note);
                db.SaveChanges();

                return(Json(new
                {
                    Result = true,
                    Data = new
                    {
                        Result = true,
                        NoteId = note.Id,
                        ClientId = note.ClientId
                    }
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = false, Message = ex.Message }));
            }
        }
示例#2
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);
            }
        }
        public IList <ClientNote> LoadClientNotesFor(int clientId)
        {
            IList <ClientNote> notes = new List <ClientNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesClient_LoadForAClient",
                                                                          CreateNotesClientPerm_LoadForAClientParameters
                                                                              (clientId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        ClientNote note = new ClientNote(
                            cleverReader.FromBigInteger("NotesID"),
                            cleverReader.ToDate("Created"),
                            ActivityType.Parse(cleverReader.ToInteger("ActivityTypeId")),
                            NoteType.Parse(cleverReader.ToInteger("NoteTypeId")),
                            parsedNotes,
                            cleverReader.ToInteger("CreatedBy"),
                            cleverReader.ToString("EmployeeName"),
                            cleverReader.FromBigInteger("ClientID"),
                            cleverReader.ToInteger("ModifiedBy"),
                            cleverReader.ToString("ModifiedByEmployeeName"),
                            cleverReader.ToDate("Modified"));
                        notes.Add(note);
                    }
                }
            }
            return(notes);
        }
示例#4
0
        public ActionResult AddNote()
        {
            int    id      = Convert.ToInt16(Request.Form["ClientId"]);
            string Content = Request.Form["Content"];

            Client client = db.Clients.Find(id);

            if (client == null)
            {
                return(HttpNotFound());
            }

            ClientNote cn = new ClientNote();

            cn.ClientId        = id;
            cn.Note            = Content;
            cn.DateCreated     = DateTime.UtcNow.AddHours(8);
            cn.Done            = 0;
            cn.CreatedByUserId = User.Identity.GetUserId();

            db.ClientNotes.Add(cn);
            db.SaveChanges();

            return(RedirectToAction("Manage", "Clients", new { @id = id }));
        }
示例#5
0
        public ActionResult DeleteConfirmed(int id)
        {
            ClientNote clientNote = db.ClientNotes.Find(id);

            db.ClientNotes.Remove(clientNote);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#6
0
        public void UpdateClientNote(long noteId, ActivityType activityType, NoteType noteType, string newComment, int modifiedBy)
        {
            ArgumentChecker.ThrowIfNullOrEmpty(newComment, "comment");
            ClientNote clientNote = new ClientNote(noteId, activityType, noteType, newComment, modifiedBy);

            repository.UpdateClientNote(clientNote);
            view.DisplayFeedback();
        }
示例#7
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            int    employeeId = CurrentPrincipal.CffUser.EmployeeId;
            string comment    = string.IsNullOrEmpty(CommentTextBox.Text) ? "" : CommentTextBox.Text;

            if (!string.IsNullOrEmpty(comment))
            {
                //comment = comment.Replace("\n", ";");  //dbb
                comment = comment.Replace("\n", " ");
            }

            ICffClient xClient = (SessionWrapper.Instance.Get != null) ? SessionWrapper.Instance.Get.ClientFromQueryString :
                                 (!string.IsNullOrWhiteSpace(QueryString.ViewIDValue)) ? SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).ClientFromQueryString : null;

            bool bIsAllClientsSelected = (SessionWrapper.Instance.Get != null) ? SessionWrapper.Instance.Get.IsAllClientsSelected :
                                         (!string.IsNullOrEmpty(QueryString.ViewIDValue)) ? SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).IsAllClientsSelected : false;

            bool bIsClientSelected = (SessionWrapper.Instance.Get != null) ? SessionWrapper.Instance.Get.IsClientSelected :
                                     (!string.IsNullOrEmpty(QueryString.ViewIDValue)) ? SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).IsClientSelected : false;

            bool bIsCustomerSelected = (SessionWrapper.Instance.Get != null) ? SessionWrapper.Instance.Get.IsCustomerSelected :
                                       (!string.IsNullOrEmpty(QueryString.ViewIDValue)) ? SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).IsCustomerSelected : false;

            if (bIsAllClientsSelected)
            {
                int clientId      = SessionWrapper.Instance.Get.ClientFromQueryString.Id;
                var permanentNote = new PermanentClientNote(comment, clientId, employeeId);
                presenter.SaveClientPermanentNote(permanentNote);
            }
            else if (bIsCustomerSelected)
            {
                //int customerId = SessionWrapper.Instance.Get.Customer.Id;
                int          customerId      = SessionWrapper.Instance.Get.CustomerFromQueryString.Id;
                string       nextCallDueText = EncodedText(NextCallDueTextBox.Text);
                ActivityType activityType    = ActivityType.Parse(int.Parse(ActivityTypeDropDownList.SelectedValue));
                NoteType     noteType        = NoteType.Parse(int.Parse(NoteTypeDropDownList.SelectedValue));

                SaveNoteForCustomer(comment, employeeId, customerId, nextCallDueText, activityType, noteType);
            }
            else if (bIsClientSelected)
            {
                if (PermanentNoteCheckBox.Checked)
                {
                    int clientId      = xClient.Id;
                    var permanentNote = new PermanentClientNote(comment, clientId, employeeId);
                    presenter.SaveClientPermanentNote(permanentNote);
                }
                else
                {
                    int          clientId     = xClient.Id;
                    ActivityType activityType = ActivityType.Parse(int.Parse(ActivityTypeDropDownList.SelectedValue));
                    NoteType     noteType     = NoteType.Parse(int.Parse(NoteTypeDropDownList.SelectedValue));
                    var          clientNote   = new ClientNote(activityType, noteType, comment, clientId, employeeId);
                    presenter.SaveClientNote(clientNote);
                }
            }
        }
        public HttpResponseMessage EditClientNote(HttpRequestMessage request, [FromBody] ClientNote clientNote)
        {
            return(Execute(request, () =>
            {
                _clientNoteService.Edit(clientNote);

                return request.CreateResponse(HttpStatusCode.OK);
            }));
        }
示例#9
0
        private void PopulateClientNotesControls(ClientNote selectedClientNote)
        {
            PopulateNoteTypes(NoteType.KnownTypesForNewNotes);
            PopulateActivityTypes(ActivityType.KnownTypesForNewNotes);

            CommentEditTextBox.Text = EncodedText(CustomerNotesParser.RemoveBr(selectedClientNote.Comment));
            ActivityTypeDropDownList.SelectedValue = selectedClientNote.ActivityType.Id.ToString();
            NoteTypeDropDownList.SelectedValue     = selectedClientNote.NoteType.Id.ToString();
        }
        public void DisplayRetentionNotes(IRetentionNote retentionNote)
        {
            retentionNotes = new List <ClientNote>();

            RetentionNotesLiteral.Text = retentionNote.GetNote();
            ClientNote retnClientNote = new ClientNote(ActivityType.AllNotes, NoteType.AllNotes,
                                                       retentionNote.GetNote(), 0, 0);

            retentionNotes.Add(retnClientNote);
        }
示例#11
0
 public void Show(ClientNote selectedClientNote)
 {
     PopulateClientNotesControls(selectedClientNote);
     CommentEditTextBox.Text = EncodedText(CustomerNotesParser.RemoveBr(selectedClientNote.Comment));
     CommentEditTextBox.Focus();
     ViewState.Add(SelectedNote, selectedClientNote);
     CustomerNoteDescriptors.Visible = true;
     Visible = true;
     BlockScreen();
 }
 public void InsertClientNote(ClientNote clientNote)
 {
     ArgumentChecker.ThrowIfNull(clientNote, "clientNote");
     using (SqlConnection connection = CreateConnection())
     {
         SqlHelper.ExecuteNonQuery(connection,
                                   CommandType.StoredProcedure,
                                   "NoteClient_Save", CreateSaveClientNoteParameters(clientNote));
     }
 }
示例#13
0
 public ActionResult Edit([Bind(Include = "Id,Text,UserId,ClientId,Active")] ClientNote clientNote)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clientNote).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId   = new SelectList(db.AspNetUsers, "Id", "FullName", clientNote.UserId);
     ViewBag.ClientId = new SelectList(db.Clients, "Id", "FullName", clientNote.ClientId);
     return(View(clientNote));
 }
示例#14
0
        private void UpdateClientNote(object orginalNote, int modifiedBy, string newComment)
        {
            newComment = newComment.Replace("&amp;", "&");
            NoteType     noteType     = NoteType.Parse(int.Parse(NoteTypeDropDownList.SelectedValue));
            ActivityType activityType = ActivityType.Parse(int.Parse(ActivityTypeDropDownList.SelectedValue));

            ClientNote originalCustomerNote = orginalNote as ClientNote;

            if (originalCustomerNote != null)
            {
                presenter.UpdateClientNote(originalCustomerNote.NoteId, activityType, noteType, newComment, modifiedBy);
            }
        }
示例#15
0
        public ActionResult Create([Bind(Include = "Id,Date,Text,UserId,ClientId,Active")] ClientNote clientNote)
        {
            if (ModelState.IsValid)
            {
                db.ClientNotes.Add(clientNote);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId   = new SelectList(db.AspNetUsers, "Id", "Email", clientNote.UserId);
            ViewBag.ClientId = new SelectList(db.Clients, "Id", "FirstName", clientNote.ClientId);
            return(View(clientNote));
        }
示例#16
0
        // GET: ClientNotes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClientNote clientNote = db.ClientNotes.Find(id);

            if (clientNote == null)
            {
                return(HttpNotFound());
            }
            return(View(clientNote));
        }
示例#17
0
        // GET: ClientNotes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClientNote clientNote = db.ClientNotes.Find(id);

            if (clientNote == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserId   = new SelectList(db.AspNetUsers, "Id", "FullName", clientNote.UserId);
            ViewBag.ClientId = new SelectList(db.Clients, "Id", "FullName", clientNote.ClientId);
            return(View(clientNote));
        }
示例#18
0
        public ActionResult RemoveNote(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClientNote cn = db.ClientNotes.Find(id);

            if (cn == null)
            {
                return(HttpNotFound());
            }

            db.ClientNotes.Remove(cn);
            db.SaveChanges();

            return(RedirectToAction("Manage", "Clients", new { @id = cn.ClientId }));
        }
        private static SqlParameter[] CreateUpdateClientNoteParameters(ClientNote clientNote)
        {
            SqlParameter noteIdParameter         = new SqlParameter("@NoteId", SqlDbType.Int);
            SqlParameter activityTypeIdParameter = new SqlParameter("@ActivityTypeId", SqlDbType.Int);
            SqlParameter noteTypeIdParameter     = new SqlParameter("@NoteTypeId", SqlDbType.Int);
            SqlParameter modifiedByParameter     = new SqlParameter("@ModifiedBy", SqlDbType.Int);
            SqlParameter noteParamter            = new SqlParameter("@Comment", SqlDbType.Text);

            noteIdParameter.Value         = clientNote.NoteId;
            modifiedByParameter.Value     = clientNote.ModifiedBy;
            noteParamter.Value            = clientNote.Comment;
            activityTypeIdParameter.Value = clientNote.ActivityType.Id;
            noteTypeIdParameter.Value     = clientNote.NoteType.Id;

            return(new[]
            {
                noteIdParameter, activityTypeIdParameter, noteTypeIdParameter, modifiedByParameter,
                noteParamter
            });
        }
        private static SqlParameter[] CreateSaveClientNoteParameters(ClientNote note)
        {
            SqlParameter customerIdParameter     = new SqlParameter("@ClientID", SqlDbType.Int);
            SqlParameter createdByParameter      = new SqlParameter("@CreatedBy", SqlDbType.Int);
            SqlParameter noteParamter            = new SqlParameter("@Note", SqlDbType.Text);
            SqlParameter activityTypeIdParameter = new SqlParameter("@ActivityTypeId", SqlDbType.Int);
            SqlParameter noteTypeIdParameter     = new SqlParameter("@NoteTypeId", SqlDbType.Int);

            customerIdParameter.Value     = note.ClientId;
            createdByParameter.Value      = note.AuthorId;
            noteParamter.Value            = note.Comment;
            activityTypeIdParameter.Value = note.ActivityType.Id;
            noteTypeIdParameter.Value     = note.NoteType.Id;

            return(new[]
            {
                customerIdParameter, createdByParameter, noteParamter, activityTypeIdParameter,
                noteTypeIdParameter
            });
        }
示例#21
0
        public List <ClientNote> GetClientNotesByClientId(int clientId)
        {
            List <ClientNote> clientNoteList = new List <ClientNote>();
            List <int>        foundIds       = new List <int>();
            bool done = false;

            while (!done)
            {
                ClientNote getClientNote = _repository.Get(filter => filter.ClientId == clientId, l => !foundIds.Contains(l.Id)).FirstOrDefault();
                if (getClientNote != null)
                {
                    clientNoteList.Add(getClientNote);
                    foundIds.Add(getClientNote.Id);
                }
                else
                {
                    done = true;
                }
            }
            return(clientNoteList);
        }
示例#22
0
 public bool UpdateClientNotes(ClientNote clientNote, ref string errMsg)
 {
     try
     {
         repository.UpdateClientNote(clientNote);
         return(true);
     }
     catch (System.Exception exc)
     {
         if (exc.Message.ToLower().IndexOf("foreign key constraint", 0) > 0 &&
             (exc.Message.ToLower().IndexOf("activitytype", 0) > 0) && clientNote.ActivityType.Id >= 0)
         {
             errMsg = "Unable to modify notes for this activity type.";
         }
         else
         {
             errMsg = exc.Message;
         }
         return(false);
     }
 }
 public void Add(ClientNote entity)
 {
     Repository.Add(entity);
 }
        public IList <ClientNote> LoadClientNotesOnRange(int clientId, DateRange dateRange)
        {
            ArgumentChecker.ThrowIfNull(dateRange, "fromDate");
            SqlParameter[] sqlParameters = new[]
            {
                CreateClientIdParameter(clientId),
                CreateFromDateParameter(dateRange.StartDate),
                CreateToDateParameters(dateRange.EndDate)
            };
            IList <ClientNote> notes = new List <ClientNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesClient_LoadForAClientOnRange",
                                                                          sqlParameters))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string     parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));
                        ClientNote note        = null;

                        if (clientId > 0)
                        {
                            note = new ClientNote(
                                cleverReader.FromBigInteger("NotesID"),
                                cleverReader.ToDate("Created"),
                                ActivityType.Parse(cleverReader.ToInteger("ActivityTypeId")),
                                NoteType.Parse(cleverReader.ToInteger("NoteTypeId")),
                                parsedNotes,
                                cleverReader.ToInteger("CreatedBy"),
                                cleverReader.ToString("EmployeeName"),
                                cleverReader.FromBigInteger("ClientID"),
                                cleverReader.ToInteger("ModifiedBy"),
                                cleverReader.ToString("ModifiedByEmployeeName"),
                                cleverReader.ToDate("Modified"));
                        }
                        else
                        {
                            note = new ClientNote(
                                cleverReader.FromBigInteger("NotesID"),
                                cleverReader.ToDate("Created"),
                                ActivityType.Parse(cleverReader.ToInteger("ActivityTypeId")),
                                NoteType.Parse(cleverReader.ToInteger("NoteTypeId")),
                                parsedNotes,
                                cleverReader.ToInteger("CreatedBy"),
                                cleverReader.ToString("EmployeeName"),
                                cleverReader.FromBigInteger("ClientID"),
                                cleverReader.ToInteger("ModifiedBy"),
                                cleverReader.ToString("ModifiedByEmployeeName"),
                                cleverReader.ToDate("Modified"),
                                cleverReader.ToString("ClientName"));
                        }

                        if (note != null)
                        {
                            notes.Add(note);
                        }
                    }
                }
            }
            return(notes);
        }
示例#25
0
 public ClientNoteResult(ClientNote clientNote)
 {
     Id   = clientNote.Id;
     Note = clientNote.Note;
 }
 public void SaveClientNote(ClientNote clientNote)
 {
     ArgumentChecker.ThrowIfNull(clientNote, "clientNote");
     notesRepository.InsertClientNote(clientNote);
     view.DisplayFeedback();
 }
示例#27
0
 public void Add(ClientNote clientNote)
 {
     _repository.Add(clientNote);
     _uow.Commit();
 }
示例#28
0
 public void Delete(ClientNote clientNote)
 {
 }
示例#29
0
 public void Edit(ClientNote clientNote)
 {
     _repository.Edit(clientNote);
     _uow.Commit();
 }
 public void Delete(ClientNote entity)
 {
     Repository.Delete(entity);
 }