/// <summary> /// Delete for User object /// if excepion happeneds during Table operation it must be cought in calling method. /// </summary> /// <param name="obj">instance of User class to be inserted </param> /// <param name="AddToContext">bool paremeter tell the Context to attach object if it is not tracked by this instance of the Context </param> public void DeleteObject(User obj, bool AddToContext) { if (AddToContext) servCtx.AttachTo(TableName, obj.InternalEntity, "*"); servCtx.DeleteObject(obj.InternalEntity); servCtx.SaveChangesWithRetries(); }
internal static User FromModel(UserModel model, User user) { if (!String.IsNullOrEmpty(model.UserName)) user.UserName = model.UserName; if (!String.IsNullOrEmpty(model.Password)) user.Password = model.Password; user.IsActive = model.IsActive; user.IsAdmin = model.IsAdmin; if (!String.IsNullOrEmpty(model.Gender)) user.Gender = model.Gender; user.Latitude = model.Latitude; user.Longitude = model.Longitude; if (!String.IsNullOrEmpty(model.ChatId)) user.ChatId = model.ChatId; if (!String.IsNullOrEmpty(model.DeviceId)) user.DeviceId = model.DeviceId; if (!String.IsNullOrEmpty(model.DeviceName)) user.DeviceName = model.DeviceName; if (!String.IsNullOrEmpty(model.DeviceVersion)) user.DeviceVersion = model.DeviceVersion; if (!String.IsNullOrEmpty(model.DevicePlatform)) user.DevicePlatform = model.DevicePlatform; if (!String.IsNullOrEmpty(model.DevicePhGapVersion)) user.DevicePhGapVersion = model.DevicePhGapVersion; if (!string.IsNullOrEmpty(model.FacebookId)) user.FacebookId = model.FacebookId; user.IsOnline = model.IsOnline; if (model.AppState != AppStateType.NoState) user.AppState = model.AppState; user.AgeCheck = (model.AppState == AppStateType.AgeCheckComplete) ? user.AgeCheck = true : user.AgeCheck = false; user.TCCheck = (model.AppState == AppStateType.TCComplete) ? user.TCCheck = true : user.TCCheck = false; return user; }
internal static UserModel FromEntity(User user) { return new UserModel { UserId = user.UserId, UserName = user.UserName, IsAdmin = user.IsAdmin, Gender = user.Gender, IsActive = user.IsActive, Latitude = user.Latitude, Longitude = user.Longitude, ChatId = user.ChatId , DeviceId = user.DeviceId , DeviceName = user.DeviceName, DeviceVersion = user.DeviceVersion , DevicePlatform = user.DevicePlatform , DevicePhGapVersion = user.DevicePhGapVersion , IsOnline = user.IsOnline , FacebookId= user.FacebookId , AppState = user.AppState , FirstName = user.FirstName, LastName = user.LastName , Locale = user.Locale}; }
private void UpdateUserDevices(User user) { UserDeviceContext udCtx = new UserDeviceContext(); UserDevice userDev = udCtx.GetById(user.UserId , user.DeviceId); if (userDev == null) udCtx.AddObject(new UserDevice { UserId = user.UserId, DeviceId = user.DeviceId, DeviceName = user.DeviceName, DevicePlatform = user.DevicePlatform, DevicePhGapVersion = user.DevicePhGapVersion, DeviceVersion = user.DeviceVersion }); else { userDev.DeviceName = user.DeviceName; userDev.DevicePlatform = user.DevicePlatform; userDev.DevicePhGapVersion = user.DevicePhGapVersion; userDev.DeviceVersion = user.DeviceVersion; udCtx.UpdateObject(userDev,false); } }
private bool IsLocationChanged(UserModel model, User user) { return (model.Longitude != user.Longitude || model.Latitude != user.Latitude); }
private bool IsDeviceIdChanged(UserModel model, User user) { return (model.DeviceId != user.DeviceId); }
private bool IsChatIdChanged(UserModel model, User user) { return (model.ChatId != user.ChatId); }
private static bool DoesFacebookUserExists(UserModel model, User user) { if (user!=null && !string.IsNullOrEmpty(user.FacebookId) && user.FacebookId == model.FacebookId) { return true; } return false; }
/// <summary> /// Insert for User object /// if excepion happeneds during Table operation it must be cought in calling method. /// </summary> /// <param name="obj">instance of User class to be inserted </param> public void AddObject(User obj ) { servCtx.AddObject(TableName, obj.InternalEntity); servCtx.SaveChangesWithRetries(); }