public PartialViewResult GetRolePunish() { try { var data = new spin_role(); var today = DateTime.Parse(DateTime.Now.ToString("MM/dd/yyyy")); var check_data = _queryBuilder.Query(ConstantsDatabase.TABLE_USER_TASKS + " as ut") .Join(ConstantsDatabase.TABLE_USERS + " as u", "u.id", "ut.user_id") .Where("ut.date", ">=", today.AddDays(-1)) .Where("ut.date", "<", today) .Select("u.*") .FirstOrDefault <user>(); var id_fb = HttpContext.Session.GetString(Constants.ID_FACEBOOK); var check_admin = _queryBuilder.Query(ConstantsDatabase.TABLE_USERS) .Where(ConstantsDatabase.USERS_ID_FACEBOOK, id_fb) .FirstOrDefault <user>(); data.is_admin = check_admin.actived == 100 ? true : false; if (check_data.id == check_admin.id) { data.is_spiner = true; data.full_name = check_data.full_name; } else { data.is_spiner = false; data.full_name = check_data.full_name; } return(PartialView("RolePunishPartialView", data)); } catch { return(PartialView("RolePunishPartialView", new spin_role())); } }
public PartialViewResult GetSpinHeader() { try { var data = new spin_role(); var id_fb = HttpContext.Session.GetString(Constants.ID_FACEBOOK).ToString(); var user_spiner = _queryBuilder.Query(ConstantsDatabase.TABLE_USERS) .Where(ConstantsDatabase.USERS_IS_SPINER, 1) .FirstOrDefault <user>(); var this_user = _queryBuilder.Query(ConstantsDatabase.TABLE_USERS) .Where(ConstantsDatabase.USERS_ID_FACEBOOK, id_fb) .FirstOrDefault <user>(); if (user_spiner.id == this_user.id) { data.is_admin = this_user.actived == 100 ? true : false; data.is_spiner = true; data.full_name = user_spiner.full_name; } else if (this_user.actived == 100) { data.is_admin = true; data.is_spiner = false; data.full_name = user_spiner.full_name; } else { data.is_admin = false; data.is_spiner = false; data.full_name = user_spiner.full_name; } return(PartialView("RolePartialView", data)); } catch (Exception ex) { return(PartialView("RolePartialView", new spin_role() { is_spiner = false, full_name = "(Lấy dữ liệu lỗi rồi)" })); } }