public ActionResult ContactRequest(NameValueCollection postedData) { NameValueCollection qury = Request.QueryString; UserAccount userToBe = new UserAccount(qury["username"]); UserConnection ucToSet = new UserConnection(); mu = Membership.GetUser(); ucToSet.GetUserToUserConnection( Convert.ToInt32(Membership.GetUser().ProviderUserKey), userToBe.UserAccountID); if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "0") { // they never set anything up and are ending the request Response.Redirect("~/" + userToBe.UserName); } else if (ucToSet.UserConnectionID != 0 && qury["rslt"] == "0") { if (Convert.ToInt32(mu.ProviderUserKey) != ucToSet.CreatedByUserID) { // one user sent a request and now it's rejected ucToSet.StatusType = 'L'; ucToSet.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.IsConfirmed = true; ucToSet.Update(); Response.Redirect("/" + Membership.GetUser().UserName); } else { // this is assumed to be not a declude because it is a reject by the issuer Response.Redirect("/" + userToBe.UserName); } } else if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "1") { // they are not yet connected and are requesting to begin a connection ucToSet.IsConfirmed = false; ucToSet.CreatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.FromUserAccountID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.ToUserAccountID = userToBe.UserAccountID; ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Create(); Response.Redirect("/" + userToBe.UserName); } else if (ucToSet.UserConnectionID > 0 && qury["rslt"] == "1") { // there was a request that is being confirmed if (ucToSet.StatusType == Convert.ToChar(qury["contacttype"])) { ucToSet.IsConfirmed = true; } else { // upgrading the request ucToSet.IsConfirmed = false; if (Convert.ToInt32(mu.ProviderUserKey) == ucToSet.ToUserAccountID) { // the opposite this time ucToSet.FromUserAccountID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.ToUserAccountID = userToBe.UserAccountID; } } ucToSet.UpdatedByUserID = Convert.ToInt32(mu.ProviderUserKey); ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Update(); switch (Convert.ToChar(qury["contacttype"])) { case 'R': if (ucToSet.IsConfirmed) { Response.Redirect("~/account/irlcontacts/" + mu.UserName); } else { Response.Redirect("/" + userToBe.UserName); } break; case 'C': if (ucToSet.IsConfirmed) { Response.Redirect("~/account/CyberAssociates/" + mu.UserName); } else { Response.Redirect("~/" + userToBe.UserName); } break; case 'L': Response.Redirect("~/" + mu.UserName); break; default: break; } } else { // ??? } return View(); }
public ActionResult ConfirmContactRequest(string input) { NameValueCollection qury = HttpUtility.ParseQueryString(input); var userToBe = new UserAccount(qury["username"]); var ucToSet = new UserConnection(); if (_mu != null) ucToSet.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), userToBe.UserAccountID); if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "0") { // they never set anything up and are ending the request Response.Redirect("~/" + userToBe.UserName); } else if (ucToSet.UserConnectionID != 0 && qury["rslt"] == "0") { if (_mu != null && Convert.ToInt32(_mu.ProviderUserKey) != ucToSet.CreatedByUserID) { // one user sent a request and now it's rejected ucToSet.StatusType = 'L'; ucToSet.UpdatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.IsConfirmed = true; ucToSet.Update(); if (_mu != null) Response.Redirect("/" + _mu.UserName); } else { // this is assumed to be not a declude because it is a reject by the issuer Response.Redirect("/" + userToBe.UserName); } } else if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "1") { // they are not yet connected and are requesting to begin a connection ucToSet.IsConfirmed = false; if (_mu != null) { ucToSet.CreatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); } ucToSet.ToUserAccountID = userToBe.UserAccountID; ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Create(); Response.Redirect("/" + userToBe.UserName); } else if (ucToSet.UserConnectionID > 0 && qury["rslt"] == "1") { // there was a request that is being confirmed if (ucToSet.StatusType == Convert.ToChar(qury["contacttype"])) { ucToSet.IsConfirmed = true; } else { // upgrading the request ucToSet.IsConfirmed = false; if (_mu != null && Convert.ToInt32(_mu.ProviderUserKey) == ucToSet.ToUserAccountID) { // the opposite this time ucToSet.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.ToUserAccountID = userToBe.UserAccountID; } } if (_mu != null) ucToSet.UpdatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Update(); switch (Convert.ToChar(qury["contacttype"])) { case 'R': if (ucToSet.IsConfirmed) { if (_mu != null) { Response.Redirect("~/account/irlcontacts/" + _mu.UserName); } } else { var requestedUserDetails = new UserAccountDetail(); requestedUserDetails.GetUserAccountDeailForUser(userToBe.UserAccountID); NotifyUserOfContactRequest(userToBe); Response.Redirect("/" + userToBe.UserName); } break; case 'C': if (ucToSet.IsConfirmed) { if (_mu != null) { Response.Redirect("~/account/CyberAssociates/" + _mu.UserName); } } else { NotifyUserOfContactRequest(userToBe); Response.Redirect("~/" + userToBe.UserName); } break; case 'L': if (_mu != null) Response.Redirect("~/" + _mu.UserName); break; } } return View(); }