public async Task <IActionResult> Create(ContactCreateViewModel contact) { //create new instance of contact var c = new Contact() { FirstName = contact.FirstName, LastName = contact.LastName, Email = contact.Email, Phone = contact.Phone }; _context.Contact.Add(c); _context.SaveChanges(); //create new instance of jobnote var note = new ContactNotes() { User = await _userManager.GetUserAsync(User), ContactId = c.Id, Notes = contact.Note }; _context.ContactNotes.Add(note); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public static int UpdateContactNote(object noteOBJ) { ContactNotes note = new ContactNotes(); note.Clone(noteOBJ); note.Update(); return(note.Id); }
public async Task <IActionResult> Create(int ContactMethods, bool Success, DateTime Date, string AlumFirst, string AlumLast, string Initiator, string Notes) { Contact contact = new Contact(); if (Date != null) { contact.Date = Date; } else { contact.Date = DateTime.Now; } contact.AlumId = _context.Alum.Where(a => a.FirstName == AlumFirst && a.LastName == AlumLast).Single().Id; string alumFullName = AlumFirst + " " + AlumLast; contact.ContactTypeId = ContactMethods; contact.StaffId = _context.Staff.Where(s => s.Name == Initiator).Single().Id; var noteToAdd = new Note { Detail = Notes }; _context.Note.Add(noteToAdd); await _context.SaveChangesAsync(); contact.NoteId = noteToAdd.Id; contact.Success = Success; if (ModelState.IsValid) { _context.Contact.Add(contact); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { id = contact.AlumId })); } ContactNotes viewModel = new ContactNotes() { AlumName = alumFullName, Date = Date, Initiator = Initiator, ContactMethods = _context.ContactType.ToList(), Success = Success, Notes = Notes, ContactHistory = PopulateHistoricalContacts(contact.AlumId) }; return(View(viewModel)); }
public async Task <IActionResult> AddNote(int id, ContactAddNoteViewModel contactNote) { var note = new ContactAddNoteViewModel() { User = await _userManager.GetUserAsync(User), Id = id, ContactName = contactNote.ContactName }; var cn = new ContactNotes() { User = note.User, ContactId = id, Notes = note.Note }; if (id != contactNote.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.ContactNotes.Add(cn); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(contactNote.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(contactNote)); }
/// <summary> /// load data /// </summary> /// <param name="contactId"></param> /// <param name="noteId"></param> private void BindPage(int contactId, int noteId) { ContactNotes bllContactNotes = new ContactNotes(); Contacts bllContact = new Contacts(); LPWeb.Model.Contacts modelContact = bllContact.GetModel(contactId); if (modelContact != null) { lblProperty.Text = modelContact.MailingAddr + " " + modelContact.MailingCity + " " + modelContact.MailingState + " " + modelContact.MailingZip; } var curUser = new LoginUser(); lblSender.Text = curUser.sFirstName + " " + curUser.sLastName; lblBorrower.Text = modelContact.LastName + ", " + modelContact.FirstName + " " + modelContact.MiddleName; if (noteId > 0) { tbxNote.Text = bllContactNotes.GetModel(noteId).Note; } }
public static void DeleteContactNote(int id) { ContactNotes.DeleteContactNote(id); }
public static List <ContactNotes> GetListOfContactNotes() { return(ContactNotes.LoadList()); }
public static ContactNotes GetContactNote(int id) { return(ContactNotes.GetContactNote(id)); }
protected void btnSave_Click(object sender, EventArgs e) { string err = ""; try { if (tbxNote.Text.Trim() == "") { PageCommon.AlertMsg(this, "Please input the note!"); return; } //if (tbxNote.Text.Trim().Length > 500) //{ // PageCommon.AlertMsg(this, "The note length must be less than 500 characters!"); // return; //} int contactId = int.Parse(hfdContactId.Value); var curUser = new LoginUser(); string senderName = curUser.sFirstName + " " + curUser.sLastName; var req = new AddNoteRequest { FileId = contactId, Created = DateTime.Now, Note = tbxNote.Text.Trim(), Sender = senderName, hdr = new ReqHdr { UserId = curUser.iUserID } }; ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { //AddNoteResponse res = client.AddNote(req); //bool exported = !res.hdr.Successful ? false : true; bool exported = true; LPWeb.Model.ContactNotes model = new LPWeb.Model.ContactNotes { Note = tbxNote.Text, ContactId = contactId, Created = DateTime.Now, CreatedBy = curUser.iUserID }; ContactNotes bllContactNotes = new ContactNotes(); bllContactNotes.Add(model); //if (!exported) //{ // PageCommon.WriteJs(this, res.hdr.StatusInfo, "parent.ClosePopupWindow();"); //} //else //{ PageCommon.WriteJs(this, "Added note successfully.", "parent.ClosePopupWindow();"); //PageCommon.WriteJsEnd(this, "Add note Failed.", PageCommon.Js_RefreshSelf); //} } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); PageCommon.AlertMsg(this, "Failed to add note, reason: Point Manager is not running."); } catch (Exception exception) { err = "Failed to add note, reason:" + exception.Message; LPLog.LogMessage(err); PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf); } }