Exemple #1
0
 public Domain.Socioboard.Domain.NewsLetterSetting getNewsLetterSettings(string userId)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         try
         {
             Domain.Socioboard.Domain.NewsLetterSetting _NewsLetterSetting = session.Query <Domain.Socioboard.Domain.NewsLetterSetting>().Where(t => t.userId == userId).SingleOrDefault();
             return(_NewsLetterSetting);
         }
         catch (Exception ex)
         {
             return(new NewsLetterSetting());
         }
     }
 }
        public async Task<ActionResult> LoadPersonalSetting()
        {
              User objUser = (User)Session["User"];
              NewsLetterSetting _NewsLetterSetting = new NewsLetterSetting();

              HttpResponseMessage response = await WebApiReq.GetReq("api/ApiNewsLetter/Get?userId=" + objUser.Id.ToString(), "Bearer", Session["access_token"].ToString());
              if (response.IsSuccessStatusCode)
              {
                  _NewsLetterSetting = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.NewsLetterSetting>();
              }
              else {
                  _NewsLetterSetting = null;
              }
              ViewBag.NewsLetterSetting = _NewsLetterSetting;
              return PartialView("_PersonalSettingPartial", objUser);
        }
 public async Task<ActionResult> UpdateNewsLatter(string _daily, string _15, string _30, string _60, string _90, string _others)
 {
     NewsLetterSetting _NewsLetterSetting = new NewsLetterSetting();
     User _user=(User)Session["User"];
     List<KeyValuePair<string, string>> _Parameters = new List<KeyValuePair<string, string>>();
     _Parameters.Add(new KeyValuePair<string,string>("userId",_user.Id.ToString()));
     _Parameters.Add(new KeyValuePair<string, string>("groupReport_Daily",_daily));
     _Parameters.Add(new KeyValuePair<string, string>("groupReport_7", _15));
     _Parameters.Add(new KeyValuePair<string, string>("groupReport_15", _15));
     _Parameters.Add(new KeyValuePair<string, string>("groupReport_30", _30));
     _Parameters.Add(new KeyValuePair<string, string>("groupReport_60", _60));
     _Parameters.Add(new KeyValuePair<string, string>("groupReport_90", _90));
     _Parameters.Add(new KeyValuePair<string, string>("others", _others));
     HttpResponseMessage _HttpResponseMessage;
     _HttpResponseMessage = await WebApiReq.PostReq("api/ApiNewsLetter/UpdateSetting", _Parameters, "Bearer", Session["access_token"].ToString());
     if (_HttpResponseMessage.IsSuccessStatusCode)
     {
         return Content("success");
     }
     else {
         return Content("failed");
     }
 }
 public bool UpdateNewsLatterSetting(NewsLetterSetting _NewsLetterSetting)
 {
     try
     {
         using (NHibernate.ISession session = SessionFactory.GetNewSession())
         {
             NewsLetterSetting objNewsLetterSetting = new NewsLetterSetting();
             try
             {
                 objNewsLetterSetting = session.Query<NewsLetterSetting>().Where(t => t.userId == _NewsLetterSetting.userId).SingleOrDefault();
             }
             catch (Exception ex)
             {
                 objNewsLetterSetting = null;
             }
             using (NHibernate.ITransaction transaction = session.BeginTransaction())
             {
                 if (objNewsLetterSetting == null)
                 {
                     session.Save(_NewsLetterSetting);
                 }
                 else
                 {
                     objNewsLetterSetting.groupReport_Daily = _NewsLetterSetting.groupReport_Daily;
                     objNewsLetterSetting.groupReport_7 = _NewsLetterSetting.groupReport_7;
                     objNewsLetterSetting.groupReport_15 = _NewsLetterSetting.groupReport_15;
                     objNewsLetterSetting.groupReport_30 = _NewsLetterSetting.groupReport_30;
                     objNewsLetterSetting.groupReport_60 = _NewsLetterSetting.groupReport_60;
                     objNewsLetterSetting.groupReport_90 = _NewsLetterSetting.groupReport_90;
                     objNewsLetterSetting.others = _NewsLetterSetting.others;
                     session.SaveOrUpdate(objNewsLetterSetting);
                 }
                 transaction.Commit();
             }
         }
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }