public ActionResult ConfirmAdoptionRequest(string text, string ReceiverId, string SenderId, int AnimalId) { var adoption = new Adoption { InterestedUserId = SenderId, PetOwnerId = ReceiverId, AnimalId = AnimalId, AdoptionStatusId = 1, AdoptionStart = DateTime.Now }; db.Adoptions.Add(adoption); db.SaveChanges(); var adoptionMail = new AdoptionMail { AdoptionId = adoption.Id, ReceiverId = ReceiverId, SenderId = SenderId, SentDate = DateTime.Now, Text = text }; db.AdoptionMails.Add(adoptionMail); db.SaveChanges(); return(RedirectToAction("PetList", "Pets")); }
public ActionResult SendMessage(string text, string petOwnerId, string interestedPartyId, string currentUserId, int adoptionId) { string receiverId, senderId; if (interestedPartyId == currentUserId) { receiverId = petOwnerId; senderId = interestedPartyId; } else { receiverId = interestedPartyId; senderId = petOwnerId; } if (!String.IsNullOrEmpty(text)) { var message = new AdoptionMail { AdoptionId = adoptionId, ReceiverId = receiverId, SenderId = senderId, SentDate = DateTime.Now, Text = text }; db.AdoptionMails.Add(message); db.SaveChanges(); } return(RedirectToAction("RenderMails", new { id = adoptionId })); }