/// <summary> /// This function will add a point depending on the action done. /// </summary> /// <param name="id">Please base the ids on the Enum Anniversary Promo</param> /// <param name="contentId">Id of the episode, show, celebrity</param> /// <param name="description">Can be the show name, celebrity name, episode name (show - date)</param> /// <returns></returns> public JsonResult NotifyAction(FormCollection fc) { int naId = 0; GigyaResponseData response = new GigyaResponseData() { errorCode = -1, errorMessage = "Unidentified error" }; if (String.IsNullOrEmpty(fc["naId"]) || String.IsNullOrEmpty(fc["naDescription"])) { response.errorMessage = "Missing parameter"; return this.Json(null, JsonRequestBehavior.AllowGet); } naId = Convert.ToInt32(fc["naId"]); string naDescription = fc["naDescription"]; if (!Request.IsLocal) if (!Request.IsAjaxRequest()) { response.errorMessage = "Invalid request"; return this.Json(null, JsonRequestBehavior.AllowGet); } if (!User.Identity.IsAuthenticated) response.errorMessage = "Unauthorized user"; else { if (!ContextHelper.IsUserPartOfPromo(GlobalConfig.TFCtvFirstYearAnniversaryPromoId, User.Identity.IsAuthenticated ? new Guid(User.Identity.Name) : Guid.Empty)) response.errorMessage = "User not in Promo"; else { try { string action = String.Empty; action = ((AnniversaryPromo)naId).ToString(); if (!String.IsNullOrEmpty(action)) { GigyaActionSingleAttribute actionAttribute = new GigyaActionSingleAttribute(); { actionAttribute.description = new List<string> { naDescription }; } response = GigyaMethods.NotifyAction(new Guid(User.Identity.Name), action, actionAttribute); } } catch (Exception) { response.errorMessage = "Invalid action"; } } } return this.Json(response, JsonRequestBehavior.AllowGet); }
public JsonResult _EnterPromo(FormCollection fc) { var ReturnCode = new TransactionReturnType() { StatusCode = (int)ErrorCodes.UnknownError, StatusMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError) }; DateTime registDt = DateTime.Now; int promoID = GlobalConfig.TFCtvFirstYearAnniversaryPromoId; var userID = new System.Guid(User.Identity.Name); try { var context = new IPTV2Entities(); Promo promo = context.Promos.FirstOrDefault(p => p.PromoId == promoID && p.StatusId == GlobalConfig.Visible && p.EndDate > registDt && p.StartDate < registDt); if (promo != null) { UserPromo userPromo = context.UserPromos.FirstOrDefault(u => u.UserId == userID && u.PromoId == promoID); if (userPromo == null) userPromo = new UserPromo() { PromoId = promoID, UserId = userID, AuditTrail = new AuditTrail() { CreatedOn = DateTime.Now } }; context.UserPromos.Add(userPromo); if (context.SaveChanges() > 0) { ReturnCode.StatusCode = (int)ErrorCodes.Success; ReturnCode.StatusMessage = "You have successfully joined the promo."; //adds points for each presconnected SNS var providers = GigyaMethods.GetUserInfoByKey(userID, "providers"); var providerList = providers.Split(','); foreach (string p in providerList) { if (!(String.Compare(p, "site") == 0)) { GigyaActionSingleAttribute actionAttribute = new GigyaActionSingleAttribute(); { actionAttribute.description = new List<string> { "You connected to " + p }; } GigyaMethods.NotifyAction(userID, AnniversaryPromo.AnnivPromo_LinkingSNS.ToString(), actionAttribute); } } } else { ReturnCode.StatusCode = (int)ErrorCodes.UnknownError; ReturnCode.StatusMessage = "You have already joined the promo."; } } } catch (Exception e) { MyUtility.LogException(e); } return this.Json(ReturnCode, JsonRequestBehavior.AllowGet); }
public static GigyaResponseData NotifyAction(Guid UserId, string action, GigyaActionSingleAttribute actionAttribute) { GigyaResponseData responseData = null; try { Dictionary<string, object> collection = new Dictionary<string, object>(); collection.Add("UID", UserId.ToString()); collection.Add("action", action); if (actionAttribute != null) collection.Add("actionAttributes", actionAttribute); GSResponse res = GigyaHelpers.createAndSendRequest("gm.notifyAction", GigyaHelpers.buildParameter(collection)); responseData = JsonConvert.DeserializeObject<GigyaResponseData>(res.GetData().ToJsonString()); } catch (Exception e) { MyUtility.LogException(e); } return responseData; }