public JsonResult AddLike(int idSotr)
        {
            try
            {
                int userId =
              JsonConvert.DeserializeObject<ClientUser>(
                  FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).UserData).Id;

                if (ILikesService.IsUserAddLike(userId, idSotr))
                {
                    Prepod_PrepodLikes prepodLike = new Prepod_PrepodLikes()
                         {
                             IdSotr = idSotr,
                             IdUser = userId
                         };

                    ILikesService.AddLike(prepodLike);
                    int count = ILikesService.GetPrepodLikesCount(idSotr);
                    return Json(new { type = "success", count = count });
                }

                return Json(new { type = "error", message = "Вы уже ставили лайк" });

            }
            catch (Exception ex)
            {
                return Json(new { type = "error", message = "Ошибка при сохранении данных. " + ex.Message });
            }
        }
Example #2
0
 public void RemoveLike(Prepod_PrepodLikes prepodLike)
 {
     _dataProvider.PrepodLikes.Delete(prepodLike);
     _dataProvider.Save();
 }
Example #3
0
 public void AddLike(Prepod_PrepodLikes prepodLike)
 {
     _dataProvider.PrepodLikes.Add(prepodLike);
     _dataProvider.Save();
 }