internal bool UserLogout(ReqLogOut objReq) { using (var db = new WizzDataContext()) { tblUser tUser = new tblUser(); int fkuserid = Convert.ToInt32(objReq.userId); tUser = db.tblUsers.Where(x => x.pkUserId == fkuserid).FirstOrDefault(); if (tUser == null) return false; else { tUser.deviceToken = null; db.SubmitChanges(); return true; } } }
public Response<string> LogOutService(ReqLogOut objReq) { Response<string> response = new Response<string>(); List<string> objResp = new List<string>(); try { WebMethods objDBMethod = new WebMethods(); if (CheckRequestIsvalidornot(this.Request)) { if (ModelState.IsValid) { if (objDBMethod.UserLogout(objReq)) response.Create(true, Messages.FormatMessage(Messages.Success, "Logged out"), Messages.AppVersion, objResp); else response.Create(false, Messages.ErrorOccure, Messages.AppVersion, objResp); } else response.Create(false, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage, Messages.AppVersion, objResp); } else response.Create(false, Messages.FormatMessage(Messages.InvalidReq), Messages.AppVersion, objResp); } catch (Exception ex) { object session = new JavaScriptSerializer().Serialize(objReq); LogManager.Error("Error occured while Processing Webservice request :{0}", ex, session, ex.Message); response.Create(false, Messages.FormatMessage(Messages.ErrorOccure), Messages.AppVersion, objResp); } return response; }