public ActionResult SaveRecipient(int FilmSubmissionId, int CertificateMailingId, string FirstName, string LastName, string Suffix, string Title, string Company, string Address1, string Address2, string City, string State, string Zip, string Country, string Phone, string Fax, string Email, bool Original) { CertificateMailing cert = new CertificateMailing { FilmSubmissionId = FilmSubmissionId, CertificateMailingId = CertificateMailingId, FirstName = FirstName, LastName = LastName, Suffix = Suffix, Title = Title, Company = Company, Address1 = Address1, Address2 = Address2, City = City, State = State, Zip = Zip, Country = Country, Phone = Phone, Fax = Fax, Email = Email, Original = Original }; List <CertificateMailing> mailingList = new ContactsRepository().SaveMailingRecipient(cert, this.User.UserId); mailingList.Add(new CertificateMailing { CertificateMailingId = -1, FilmSubmissionId = FilmSubmissionId, Suffix = "" }); ViewBag.Message = "The Contact has been saved"; return(View("Contacts", mailingList)); }
/// <summary> /// Deletes a specific Certificate Mailing (Right Holder) Recipient info and retrieves the list of all existing recipients /// for the current Title /// </summary> /// <param name="cert"></param> /// <param name="userId"></param> /// <returns></returns> public List <CertificateMailing> DeleteMailingRecipient(CertificateMailing cert, int userId) { int filmSubmissionId = cert.FilmSubmissionId; CertificateMailing certOld = _context.CertificateMailings.FirstOrDefault(x => x.CertificateMailingId == cert.CertificateMailingId); _context.CertificateMailings.Remove(certOld); _context.SaveChanges(); return(_context.CertificateMailings.Where(x => x.FilmSubmissionId == filmSubmissionId).OrderBy(y => y.Original).ToList()); }
public ActionResult DeleteRecipient(int FilmSubmissionId, int CertificateMailingId) { CertificateMailing cert = new CertificateMailing { FilmSubmissionId = FilmSubmissionId, CertificateMailingId = CertificateMailingId }; List <CertificateMailing> mailingList = new ContactsRepository().DeleteMailingRecipient(cert, this.User.UserId); mailingList.Add(new CertificateMailing { CertificateMailingId = -1, FilmSubmissionId = cert.FilmSubmissionId, Suffix = "" }); ViewBag.Message = "The Contact has been deleted"; return(View("Contacts", mailingList)); }
/// <summary> /// Creates the new or updates the existing Certificate Mailing (Right Holder) Recipient info and retrieves the list of all existing recipients /// for the current Title /// </summary> /// <param name="cert"></param> /// <param name="userId"></param> /// <returns></returns> public List <CertificateMailing> SaveMailingRecipient(CertificateMailing cert, int userId) { int filmSubmissionId = cert.FilmSubmissionId; CertificateMailing certOld = _context.CertificateMailings.FirstOrDefault(x => x.CertificateMailingId == cert.CertificateMailingId); if (certOld == null) //new Recipient { cert.ModifiedBy = userId; cert.ModifiedDate = DateTime.Now; _context.CertificateMailings.Add(cert); _context.SaveChanges(); } else { certOld.Address1 = cert.Address1; certOld.Address2 = cert.Address2; certOld.City = cert.City; certOld.Company = cert.Company; certOld.Country = cert.Country; certOld.Email = cert.Email; certOld.Fax = cert.Fax; certOld.FirstName = cert.FirstName; certOld.LastName = cert.LastName; certOld.Phone = cert.Phone; certOld.State = cert.State; certOld.Suffix = cert.Suffix; certOld.Title = cert.Title; certOld.Zip = cert.Zip; certOld.Original = cert.Original; certOld.ModifiedDate = DateTime.Now; certOld.ModifiedBy = userId; _context.SaveChanges(); } return(_context.CertificateMailings.Where(x => x.FilmSubmissionId == filmSubmissionId).OrderBy(y => y.Original).ToList()); }