public ActionResult RequestSend(long?id) { if (!id.HasValue) { return(SendJsonErrorResponse("Contact ID not specified")); } // has a request already being sent? var existingRequest = repository.GetLinkRequest(sessionid.Value, id.Value); if (existingRequest == null) { // send request to friend var me = repository.GetUserById(sessionid.Value, subdomainid.Value); var friend = repository.GetUserById(id.Value); var viewdata = new ContactLinkRequestViewData { notificationLink = friend.organisation1.MASTERsubdomain.ToHostName().ToDomainUrl("/notifications"), senderEmail = me.email, senderName = string.IsNullOrEmpty(me.ToFullName().Trim()) ? accountSubdomainName : me.ToFullName() }; // save link request existingRequest = new linkRequest { userid = sessionid.Value, friendid = id.Value }; try { repository.AddLinkRequest(existingRequest); } catch (Exception ex) { return(SendJsonErrorResponse(ex)); } // send notification var notification = new Message(friend, me, subdomainid.Value); notification.SendMessage(this, repository, EmailViewType.CONTACT_LINKREQUEST, viewdata, string.Format( "<a target='_blank' href='{0}'>{1}</a> wishes to link networks with you.", me.ToProfileUrl(), viewdata.senderName), viewdata.notificationLink, MessageType.LINKREQUEST); } return(Json("".ToJsonOKMessage())); }
public void AddLinkRequest(linkRequest request) { db.linkRequests.InsertOnSubmit(request); db.SubmitChanges(); }
public void DeleteLinkRequest(linkRequest request) { db.linkRequests.DeleteOnSubmit(request); }