public static BaseActionResult UpdateUserAccessToken(UserAccessToken obj4update) { string msg; if (obj4update == null) { msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, XiaoluResources.STR_USER_ACCESS_TOKEN) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL); return(new BaseActionResult(false, msg)); } try { using (var context = new XiaoluEntities()) { var repository = new UserAccessTokenRepository(context); repository.Update(obj4update); context.SaveChanges(); msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4update.AccessToken); return(new BaseActionResult(true, msg)); } } catch (Exception e) { msg = string.Format(XiaoluResources.MSG_UPDATE_FAIL, obj4update.AccessToken) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e)); return(new BaseActionResult(false, msg)); } }
public static BaseActionResult BulkDeleteUserAccessTokenByIds(string idsStr) { string msg; string[] idArr = idsStr.Split(','); if (idArr.Length == 0) { msg = XiaoluResources.ERR_MSG_NO_RECORD_FOR_ACTION; return(new BaseActionResult(false, msg)); } try { List <UserAccessToken> list4delete = new List <UserAccessToken>(); foreach (string id in idArr) { var obj4delete = GetUserAccessTokenById(id); list4delete.Add(obj4delete); } using (var context = new XiaoluEntities()) { var repository = new UserAccessTokenRepository(context); repository.BulkDelete(list4delete); context.SaveChanges(); msg = string.Format(XiaoluResources.MSG_BULK_ACTION_SUCCESS, XiaoluResources.STR_USER_ACCESS_TOKEN, idArr.Length); return(new BaseActionResult(true, msg)); } } catch (Exception e) { msg = string.Format(XiaoluResources.MSG_BULK_ACTION_FAIL, XiaoluResources.STR_DELETE, idArr.Length) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e)); return(new BaseActionResult(false, msg, e)); } }
public static BaseActionResult CreateHistory(History obj4create) { string msg; if (obj4create == null) { msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, XiaoluResources.STR_HISTORY) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL); return(new BaseActionResult(false, msg)); } try { using (var context = new XiaoluEntities()) { var repository = new HistoryRepository(context); string newId = Guid.NewGuid().ToString(); obj4create.Id = newId; repository.Create(obj4create); context.SaveChanges(); msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, obj4create.UserId); return(new BaseActionResult(true, msg)); } } catch (Exception e) { msg = string.Format(XiaoluResources.MSG_CREATE_FAIL, obj4create.UserId) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e)); return(new BaseActionResult(false, msg)); } }
public static BaseActionResult DeleteUserAccessToken(UserAccessToken obj4delete) { using (var context = new XiaoluEntities()) { string msg; var repository = new UserAccessTokenRepository(context); if (obj4delete == null) { msg = string.Format(XiaoluResources.MSG_DELETE_SUCCESS, XiaoluResources.STR_USER_ACCESS_TOKEN) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL); return(new BaseActionResult(false, msg)); } repository.Delete(obj4delete); context.SaveChanges(); msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4delete.AccessToken); return(new BaseActionResult(true, msg)); } }
public static BaseActionResult DeleteHistory(History obj4delete) { using (var context = new XiaoluEntities()) { string msg; var repository = new HistoryRepository(context); if (obj4delete == null) { msg = string.Format(XiaoluResources.MSG_DELETE_SUCCESS, XiaoluResources.STR_HISTORY) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL); return(new BaseActionResult(false, msg)); } repository.Delete(obj4delete); context.SaveChanges(); msg = string.Format(XiaoluResources.MSG_UPDATE_SUCCESS, obj4delete.UserId); return(new BaseActionResult(true, msg)); } }