Beispiel #1
0
        public ActionResult AddToFavourites(int roid)
        {
            if (Request.IsAuthenticated)
            {
                try
                {
                    SmartService smartService = new SmartService();
                    int[]        favorite     = new int[1]; //InsertFavourites expects an array so, give it one.
                    favorite[0] = roid;

                    string key, toHash, token;
                    token = smartService.AuthToken();
                    string username = User.Identity.Name;
                    toHash = username.ToUpper() + "|" + token;
                    key    = smartService.GetMd5Hash(MD5.Create(), toHash) + "|" + username;

                    AccountType Account = smartService.GetAccountDetails(key, username);
                    TempData["Message"] = smartService.InsertFavourites(Account.userId, favorite);
                }
                catch (Exception ex)
                // apparently not throwing the expected fault exception. handling argument exception instead.
                {
                    if (ex is FaultException)
                    {
                        TempData["Error"] = "Error Message: " + ex.Message;
                    }
                    if (ex is ArgumentException)
                    {
                        TempData["Error"] = "Error Message: " + ex.Message;
                    }
                }
                return(View());
            }


            return(RedirectToAction("Login", "User", new { roid, addToFav = true }));
        }