public void CreateFriend(GasUser sender, GasUser recipient) { try { var friend = new Friend() { SenderId = sender.UserId, RecipientId = recipient.UserId, IsAccepted = false }; // need to make sure that that the sender and recipient aren't already friends... var alreadyFriends = FindFriendBySenderAndRecipient(friend.SenderId, friend.RecipientId); if (alreadyFriends != null) { throw new Exception("!!! Invalid friend request, the users are already friends or their is a pending friend request !!!"); } InsertFriend(friend); } catch (Exception e) { Debug.WriteLine(e.Message); } }
private void UpdateUser(GasUser updatedUser) { var oldUser = FindGasUser(updatedUser.UserId); _gasContext.Users.Remove(oldUser); _gasContext.Users.Add(updatedUser); _gasContext.SaveChanges(); }
public LoginPageViewModel(MainPageViewModel parent) { _user = parent.User; _parent = parent; _gasUsersController = _parent._gasContextController.GasUsersController; LoginCommand = new Command(Login); RegisterCommand = new Command(Register); }
public async Task EnsureSeedDataAsync() { if (await _userManager.FindByEmailAsync("*****@*****.**") == null) { var newUser = new GasUser() { UserName = "******", Email = "*****@*****.**" }; await _userManager.CreateAsync(newUser, "!P@ssw0rd"); var newUser1 = new GasUser() { UserName = "******", Email = "*****@*****.**" }; await _userManager.CreateAsync(newUser1, "!P@ssw0rd"); var newUser2 = new GasUser() { UserName = "******", Email = "*****@*****.**" }; await _userManager.CreateAsync(newUser2, "!P@ssw0rd"); } var rec = _context.Gases.FirstOrDefault(); if (rec == null) { string jsonString = File.ReadAllText(@"files\gas.json"); Gas[] gasArray = JsonConvert.DeserializeObject <Gas[]>(jsonString); _context.Gases.AddRange(gasArray); await _context.SaveChangesAsync(); } var rec1 = _context.GasPrices.FirstOrDefault(); if (rec1 == null) { string jsonString = File.ReadAllText(@"files\gasPrice.json"); GasPrice[] gasPriceArray = JsonConvert.DeserializeObject <GasPrice[]>(jsonString); _context.GasPrices.AddRange(gasPriceArray); _context.SaveChanges(); } }
public ManageWorkoutGroupViewModel(WorkoutGroupsPageViewModel parent, WorkoutGroup workoutGroupToManage) { _parent = parent; _workoutGroupToManage = workoutGroupToManage; _applicationUser = parent.Parent.User; WorkoutGroupName = workoutGroupToManage.WorkoutGroupName; Competitors = InitializeCompetitors(); NavigateToInviteFriendPopupViewCommand = new Command(async() => await NavigateToInviteFriendPopupView()); KickFriendFromWorkoutGroupCommand = new Command(KickFriendFromWorkoutGroup); PromoteFriendToWorkoutGroupLeaderCommand = new Command(PromoteFriendToWorkoutGroupLeader); DeleteWorkoutGroupCommand = new Command(DeleteWorkoutGroup); }
public GroupChatPageViewModel(WorkoutGroupPageViewModel parent, WorkoutGroup workoutGroup) { _parent = parent; _workoutGroup = workoutGroup; _applicationUser = _parent.Parent.Parent.User; _currentGroupChat = Task.Run(GetCurrentGroupChat).Result; SendMessageCommand = new Command(async() => await SendMessage()); new Thread(async() => await GetMessages()) { IsBackground = true }.Start(); }
/// <summary> /// 根据户号获取燃气用户 /// </summary> /// <param name="userId"></param> /// <param name="companyId"></param> /// <returns></returns> public GasUser GetGasUserByUserId(string userId, string companyId) { object o = Activator.CreateInstance(t); MethodInfo method = t.GetMethod("GetGasUserByUserId"); object [] param = { userId, companyId }; string objStr = method.Invoke(o, param).ToString(); GasUser user = JsToJson.Deserialize <GasUser>(objStr); return(user); }
/// <summary> /// »ñȡȼÆøÕ˺Š/// </summary> /// <param name="account"></param> /// <returns></returns> public List <GasUser> GetGasUserList(string account) { List <GasUser> list = new List <GasUser>(); DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString); Table <Olb_GasUserRelation> tbl = dd.GetTable <Olb_GasUserRelation>(); List <Olb_GasUserRelation> relationList = tbl.Where(p => p.Account == account).ToList(); foreach (Olb_GasUserRelation o in relationList) { GasUser user = IotMService.GetInstance().GetGasUserByUserId(o.GasUserID, o.CompanyID); list.Add(user); } return(list); }
public GasUser FindFriendsGasUserByFriend(GasUser user, Friend friend) { var userId = -1; if (user.UserId == friend.SenderId) { userId = friend.RecipientId; } else { userId = friend.SenderId; } return(FindGasUser(userId)); }
public CompetitorWorkoutDetailsPageViewModel(Workout workout) { _workout = workout; _date = _workout.GetDate; _description = _workout.Description; using (GasContext context = new GasContext()) { context.SetupServer(); GasContextController contextController = new GasContextController(context); GasUsersController usersController = contextController.GasUsersController; _user = usersController.FindGasUser(_workout.GasUserId); _competitorUsername = _user.Username; GasWorkoutsController workoutsController = contextController.GasWorkoutsController; _workout.Workouts = workoutsController.GetWorkoutsWorkoutTypes(_workout.WorkoutId).ToList(); } }
public void CreateGasUser(GasUser user) { try { if (user == null) { throw new Exception("!!! Cannot add null user !!!"); } var userExists = FindGasUser(user.Username); if (userExists != null) { throw new Exception("!!! A user already exists with that username !!!"); } InsertUser(user); } catch (Exception e) { Debug.WriteLine(e.Message); } }
// TODO: think about what the user is specifically updating, here since the entire user is being updated // it causes a loss of workouts unless the workouts are provided when updating the user // for now this is alright but when making GAS you are going to want specific update function not a generic public void UpdateGasUser(GasUser user) { try { if (user == null) { throw new Exception("!!! Cannot update null user !!!"); } var userExists = FindGasUser(user.UserId); if (userExists == null) { throw new Exception("!!! A user does not exist with that id !!!"); } UpdateUser(user); } catch (Exception e) { Debug.WriteLine(e.Message); } }
// Function for testing... public void InsertData() { Database.EnsureCreated(); var user = new GasUser() { Username = "******" }; var workout = new Workout() { Exercise = "Cardio", Length = 40, Date = DateTime.Now, GasUser = user, GasUserId = user.UserId }; user.Workouts.Add(workout); GasUsers.Add(user); Workouts.Add(workout); // Saves changes SaveChanges(); }
public IEnumerable <Friend> FindFriendsByGasUser(GasUser user) => GetFriends.Where(friend => (user.UserId == friend.SenderId) || (user.UserId == friend.RecipientId));
private void InsertUser(GasUser user) { _gasContext.Users.Add(user); _gasContext.SaveChanges(); }
public void SetUpGasUser() { var gasUser = new GasUser(); ScenarioContext.Current.Add("User", gasUser);; }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); try { switch (AjaxType) { case "GETGASUSERLIST": List <GasUser> userlist = GasUserManageService.GetInstance().GetGasUserList(base.loginOperator.Account); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <GasUser>(userlist, userlist.Count) }; break; case "GETCOMPANY": List <Company> list = IotMService.GetInstance().GetCompanyList(); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <Company>(list, list.Count) }; break; case "GETGASUSER": string companyId = "", userId = ""; if (context.Request.Form["companyId"] != null && context.Request.Form["companyId"].ToString().Trim() != string.Empty) { companyId = context.Request.Form["companyId"].ToString().Trim(); } if (context.Request.Form["userId"] != null && context.Request.Form["userId"].ToString().Trim() != string.Empty) { userId = context.Request.Form["userId"].ToString().Trim(); } if (companyId != "" && userId != "") { GasUser gasUser = IotMService.GetInstance().GetGasUserByUserId(userId, companyId); jsonMessage = new Message() { Result = true, TxtMessage = JSon.TToJson <GasUser>(gasUser) }; } break; case "ADDGASUSER": companyId = ""; userId = ""; if (context.Request.Form["companyId"] != null && context.Request.Form["companyId"].ToString().Trim() != string.Empty) { companyId = context.Request.Form["companyId"].ToString().Trim(); } if (context.Request.Form["userId"] != null && context.Request.Form["userId"].ToString().Trim() != string.Empty) { userId = context.Request.Form["userId"].ToString().Trim(); } if (companyId != "" && userId != "") { jsonMessage = GasUserManageService.GetInstance().AddGasUser(base.loginOperator.Account, userId, companyId); } break; case "DELETEGASUSER": companyId = ""; userId = ""; if (context.Request.Form["Company"] != null && context.Request.Form["Company"].ToString().Trim() != string.Empty) { companyId = context.Request.Form["Company"].ToString().Trim(); } if (context.Request.Form["UserID"] != null && context.Request.Form["UserID"].ToString().Trim() != string.Empty) { userId = context.Request.Form["UserID"].ToString().Trim(); } if (companyId != "" && userId != "") { jsonMessage = GasUserManageService.GetInstance().RemoveGasUser(base.loginOperator.Account, userId, companyId); } break; case "CHARGE": companyId = ""; userId = ""; decimal money = 0; if (context.Request.Form["companyId"] != null && context.Request.Form["companyId"].ToString().Trim() != string.Empty) { companyId = context.Request.Form["companyId"].ToString().Trim(); } if (context.Request.Form["userId"] != null && context.Request.Form["userId"].ToString().Trim() != string.Empty) { userId = context.Request.Form["userId"].ToString().Trim(); } if (context.Request.Form["money"] != null && context.Request.Form["money"].ToString().Trim() != string.Empty) { money = decimal.Parse(context.Request.Form["money"].ToString().Trim()); } if (companyId == "" || userId == "" || money == 0) { break; } string result = IotMService.GetInstance().Charge(userId, companyId, money); if (result == "") { GasUser gasUser = IotMService.GetInstance().GetGasUserByUserId(userId, companyId); Olb_PaymentRecord payMent = new Olb_PaymentRecord() { Account = base.loginOperator.Account, GasUserID = userId, PayMoney = money, PayTime = DateTime.Now, Balance = gasUser.Balance, GasUserAddress = gasUser.Address, GasUserName = gasUser.UserName }; PaymentManageService.GetInstance().AddPaymentRecord(payMent); jsonMessage = new Message() { Result = true, TxtMessage = "充值成功。" }; } break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
private void DeleteUser(GasUser user) { _gasContext.Users.Remove(user); _gasContext.SaveChanges(); }
public FriendDetailsViewModel(GasUser friend) { _friend = friend; FriendsWorkoutsString = GetFriendsWorkoutsString(friend.Username); FriendsWorkouts = GetFriendsWorkouts(); }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestGet(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.QueryString["notify_id"], Request.QueryString["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表 //商户订单号 string out_trade_no = Request.QueryString["out_trade_no"]; //支付宝交易号 string trade_no = Request.QueryString["trade_no"]; //交易状态 string trade_status = Request.QueryString["trade_status"]; if (Request.QueryString["trade_status"] == "TRADE_FINISHED" || Request.QueryString["trade_status"] == "TRADE_SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 Olb_ChargeOrder order = ChargeOrderService.GetInstance().GetChargeOrderById(out_trade_no); if (order != null) { string result = IotMService.GetInstance().Charge(order.GasUserID, order.CompanyID, (decimal)order.OrderMoney); if (result == "") { GasUser gasUser = IotMService.GetInstance().GetGasUserByUserId(order.GasUserID, order.CompanyID); Olb_PaymentRecord payMent = new Olb_PaymentRecord() { Account = order.Account, GasUserID = order.GasUserID, PayMoney = order.OrderMoney, PayTime = DateTime.Now, Balance = gasUser.Balance, GasUserAddress = gasUser.Address, GasUserName = gasUser.UserName }; PaymentManageService.GetInstance().AddPaymentRecord(payMent); //jsonMessage = new Message() { Result = true, TxtMessage = "充值成功。" }; Response.Redirect("../PayMentDetail.aspx"); } } } else { Response.Write("trade_status=" + Request.QueryString["trade_status"]); } //打印页面 Response.Write("验证成功<br />"); //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("验证失败"); } } else { Response.Write("无返回参数"); } }