public ActionResult PlanCreator(string date) { //check if the date chosen is null. If yes redirect to index page. if (String.IsNullOrEmpty(date)) { return(RedirectToAction("Index", "Home")); } //get the current logged in User's ID var currentUserId = User.Identity.GetUserId(); DateTime plandate = Convert.ToDateTime(date); UserPlan userPlan = new UserPlan(); //Check the user Id and date chosen by that user. Retrieve the plans from the database. var plans = from a in db.UserPlans where a.UserID == currentUserId && a.Date == plandate select a; //Sort them based on time to display to the user. plans = plans.OrderBy(p => p.Time); List <UserPlan> planList = new List <UserPlan>(); //Add all the plans to a list to display in view model foreach (var id in plans) { planList.Add(userPlan = db.UserPlans.Find(id.Id)); } //If no plans were found, create an object with date attribute set to display the date to the user. if (planList.Count == 0) { userPlan.Date = plandate; planList.Add(userPlan); } return(View("PlanCreator", planList)); }
public void UpsertPersonalizedPlanAsyncValidate(UserPlan userPlan) { //arrange dynamic expectedResult; Document updatedDocument = new Document(); JsonTextReader reader = new JsonTextReader(new StringReader(ShareTestData.userProfileWithSharedResource)); updatedDocument.LoadFrom(reader); dbService.UpdateItemAsync <UserProfile>( Arg.Any <string>(), Arg.Any <UserProfile>(), Arg.Any <string>()).ReturnsForAnyArgs <Document>(updatedDocument); dbService.CreateItemAsync <SharedResources>( Arg.Any <SharedResources>(), Arg.Any <string>()).ReturnsForAnyArgs <Document>(updatedDocument); //act var result = personalizedPlanBusinessLogic.UpsertPersonalizedPlanAsync(userPlan).Result; expectedResult = null; //assert Assert.Equal(expectedResult, result); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Sex,Age,Height,CurrentWeight,GoalWeight,ActivityLevel,IntensityOfThePlan,DailyVitaminA")] UserPlan user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public void FreePlan(string userId, string role) { try { var currencyDef = context.CurrencyDefinations.Where(x => x.CurrencyCode == "USD").FirstOrDefault(); decimal amt = 5 / currencyDef.CurrencyValue; UserPlan plan = new UserPlan(); plan.UserID = userId; plan.PlanDurationID = plan.PlanDurationID; plan.RoleID = Util.GetRoleIdByName(role, context); plan.ExpiryDate = DateTime.UtcNow.AddYears(1); plan.IsActive = true; plan.IsDelete = false; plan.PlanAmount = 0; plan.PaymentStatus = PaymentStatus.Completed.ToString(); plan.CreatedDate = DateTime.UtcNow; plan.UpdatedDate = DateTime.UtcNow; context.UserPlans.Add(plan); context.SaveChanges(); Util.SaveUserWallet(context, userId, 0, "Sign Up", Convert.ToInt32(amt), 0, 0, PaymentStatus.Completed.ToString(), PaymentFromSite.QuiGig.ToString(), 0, 0, "Admin"); Util.SaveActivitySignUp(context, "Congratulation! You have received " + amt + " free Quigs.", userId, userId, ProfileParameterEnum.SIGNUP.ToString(), 0, role, true, false); } catch (Exception ex) { } }
public async void UnassingUserPlan(int userId, int planId, DateTime date) { UserPlan userPlan = await FindByUserIdDateAndPlanIdAsync(userId, planId, date); if (userPlan != null) { Remove(userPlan); } }
public static void Main(string[] args) { UserPlan userPlan1 = new UserPlan { Id = 1 }; CreateHostBuilder(args).Build().Run(); }
/// <summary> /// Initialize the backtest task packet. /// </summary> public BacktestNodePacket(int userId, int projectId, string sessionId, byte[] algorithmData, decimal startingCapital, string name, UserPlan userPlan = UserPlan.Free) : base(PacketType.BacktestNode) { UserId = userId; Algorithm = algorithmData; SessionId = sessionId; ProjectId = projectId; UserPlan = userPlan; Name = name; }
public async Task <IActionResult> Create([Bind("Id,Date,Sex,Age,Height,CurrentWeight,GoalWeight,ActivityLevel,IntensityOfThePlan,DailyVitaminA")] UserPlan user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
// GET: UserPlans public ActionResult Index() { //Get the user ID of logged in User var currentUserId = User.Identity.GetUserId(); UserPlan userPlan = new UserPlan(); //check if the user ID in UserPlans table contains the current logged in User var plans = from a in db.UserPlans where a.UserID == currentUserId select a; //return a list of plans for the current user return(View(plans.ToList())); }
public ActionResult DeleteConfirmed(int id) { //On confirm find the Userplan UserPlan userPlan = db.UserPlans.Find(id); //get the plandate that the user was viewing to redirect to the same page DateTime plandate = userPlan.Date; //remove plan and save changes to database db.UserPlans.Remove(userPlan); db.SaveChanges(); return(RedirectToAction("PlanCreator", new { date = plandate })); }
public async Task AssingUserPlan(int userId, int planId, DateTime date) { UserPlan userPlan = await FindByUserIdDateAndPlanIdAsync(userId, planId, date); if (userPlan == null) { userPlan = new UserPlan { UserId = userId, PlanId = planId, DateOfUpdate = date }; await AddAsync(userPlan); } }
/// <summary> /// Created By :: Sakthivel.R /// Created On :: 15-9-2015 /// Comments :: Insertion function of UserPlan details. /// </summary> #region Insert_UserPlanCreation public string UserPlanInsert(UserPlan objUserPlan) { objEmailCampDataContext = new EmailCampDataContext(); int?totrow = 0; var Insert = (from cde in objEmailCampDataContext.spUserPlan_AllActions(objUserPlan.PK_UserPlanID, objUserPlan.FK_UserID, objUserPlan.FK_PlanID, objUserPlan.ActiveFrom, objUserPlan.ActiveTo, objUserPlan.IsActive, objUserPlan.CreatedBy, objUserPlan.CreatedOn, objUserPlan.UpdatedBy, objUserPlan.UpdatedOn, "i") select cde).ToList(); Insert = null; objEmailCampDataContext = null; return(totrow.ToString()); }
public void InsertUserPlan() { objUserPlan = new UserPlan(); objBL_UserPlan = new BL_UserPlan(); objUserPlan.FK_UserID = Convert.ToInt32(Session["UserID"].ToString()); objUserPlan.FK_PlanID = Convert.ToInt32(Request.QueryString["PlanID"].ToString()); objUserPlan.ActiveFrom = DateTime.Now; objUserPlan.ActiveTo = DateTime.Now.AddMonths(1); objUserPlan.IsActive = true; objUserPlan.CreatedBy = Convert.ToInt32(Session["UserID"].ToString()); objUserPlan.CreatedOn = DateTime.Now; objBL_UserPlan.AccessInsertUserPlan(objUserPlan); objUserPlan = null; objBL_UserPlan = null; }
public async Task <IActionResult> SavePersonalizedPlanAsync([FromBody] UserPlan userPlan) { if (userPlan != null) { var newPlan = await personalizedPlanBusinessLogic.UpsertPersonalizedPlanAsync(userPlan); if (newPlan == null) { return(StatusCode(StatusCodes.Status500InternalServerError)); } return(Ok(newPlan)); } return(StatusCode(400)); }
/// <summary> /// Initialize the backtest task packet. /// </summary> public BacktestNodePacket(int userId, int projectId, string sessionId, byte[] algorithmData, decimal startingCapital, string name, UserPlan userPlan = UserPlan.Free) : base(PacketType.BacktestNode) { UserId = userId; Algorithm = algorithmData; SessionId = sessionId; ProjectId = projectId; UserPlan = userPlan; Name = name; Language = Language.CSharp; Controls = new Controls { MinuteLimit = 500, SecondLimit = 100, TickLimit = 30 }; }
public async Task <UserPlanResponse> UnassignUserPlanAsync(int userId, int planId, DateTime date) { try { UserPlan userPlan = await _userPlanRepository.FindByUserIdDateAndPlanIdAsync(userId, planId, date); _userPlanRepository.UnassingUserPlan(userId, planId, date); await _unitOfWork.CompleteAsync(); return(new UserPlanResponse(userPlan)); } catch (Exception ex) { return(new UserPlanResponse($"An error ocurred while unassigning User to Paln {ex.Message}")); } }
public ActionResult NewPlan(string fromlocation, string location, string lat, string lon, string plandate, string time) { DateTime newTime = Convert.ToDateTime(time); TimeSpan ntime = newTime.TimeOfDay; DateTime nplandate = Convert.ToDateTime(plandate); //calculate the Day and hour from the time chosen by the user var day = Convert.ToString(nplandate.DayOfWeek); var hr = Convert.ToString(ntime.Hours); string avgCount = PedestrianCount(lat, lon, day, hr); UserPlan newPlan = new UserPlan(); Location foundLocation = new Location(); //check if the latitude and longitude values of the location chosen by user match the stored //locations in the database. var findLocation = from a in db.Locations where a.Name == location && a.Latitude == lat && a.Longitude == lon select a; //if any location is found, get the id and obtain the accessibility level for that location foreach (var id in findLocation) { foundLocation = db.Locations.Find(id.Id); if (foundLocation != null) { newPlan.AccessibilityLevel = foundLocation.AccessibilityLevel; newPlan.AccessibilityRating = foundLocation.AccessibilityRating; } } //get the current logged in User's ID var currentUserId = User.Identity.GetUserId(); newPlan.UserID = currentUserId; newPlan.StartLocation = fromlocation; newPlan.Date = nplandate; newPlan.Location = location; newPlan.Latitude = Convert.ToDouble(lat); newPlan.Longitude = Convert.ToDouble(lon); newPlan.Time = ntime; newPlan.PeopleCount = avgCount; //add useplan to the database db.UserPlans.Add(newPlan); //save changes made to the database db.SaveChanges(); //return to Plan creator action to display all plans return(RedirectToAction("PlanCreator", new { date = plandate })); }
/// <summary> /// Created By :: Sakthivel.R /// Created On :: 15-9-2015 /// Comments :: Updation function of UserPlan details. /// </summary> #region Delete_UserPlanCreation public void UserPlanDelete(int UserPlanid) { try { objEmailCampDataContext = new EmailCampDataContext(); var Delete = (from cde in objEmailCampDataContext.spUserPlan_AllActions(UserPlanid, null, null, null, null, null, null, null, null, null, "d") select cde).ToList(); Delete = null; objUserPlan = null; objEmailCampDataContext = null; } catch (Exception ex) { ex.ToString(); } }
/// <summary> /// Created By :: Sakthivel.R /// Created On :: 15-9-2015 /// Comments :: Updation function of UserPlan details. /// </summary> #region Update_UserPlanCreation public void UserPlanUpdate(UserPlan objUserPlan) { try { objEmailCampDataContext = new EmailCampDataContext(); var Update = (from cde in objEmailCampDataContext.spUserPlan_AllActions(objUserPlan.PK_UserPlanID, objUserPlan.FK_UserID, objUserPlan.FK_PlanID, objUserPlan.ActiveFrom, objUserPlan.ActiveTo, objUserPlan.IsActive, objUserPlan.CreatedBy, objUserPlan.CreatedOn, objUserPlan.UpdatedBy, objUserPlan.UpdatedOn, "u") select cde).ToList(); Update = null; objUserPlan = null; objEmailCampDataContext = null; } catch (Exception ex) { ex.ToString(); } }
// GET: UserPlans/Delete/5 public ActionResult Delete(int?id) { //check if ID is null. if (id == null) { //return bad request page return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //Find the plan ID to delete. UserPlan userPlan = db.UserPlans.Find(id); //Return not found is the Object is empty if (userPlan == null) { return(HttpNotFound()); } //return a view with the details of the user plan to be deleted return(View(userPlan)); }
public ActionResult Plan() { ViewBag.IsCardAdded = false; ViewBag.TrailEnd = SessionData.TrialEndOn; var plan = new UserPlan(); DataTable dt = null, dt1 = null; UserPlanData pdata = new UserPlanData(); var ds = pdata.GetPlanData(SessionData.UserID); dt = ds.Tables[0]; dt1 = ds.Tables[1]; if (dt != null && dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; String PlanNextDate = dr.Field <DateTime?>("PlanEndDate") == null ? "" : Convert.ToDateTime(dr["PlanEndDate"]).ToString(); plan.NextDate = PlanNextDate; } if (dt1 != null && dt1.Rows.Count > 0) { DataRow dr1 = dt1.Rows[0]; plan.SkuCount = Convert.ToInt32(dr1["SKU"]); plan.KeyCount = Convert.ToInt32(dr1["Keyword"]); if (plan.SkuCount > 250) { plan.Price = UserPlans.GetCustomPlanCost(plan.SkuCount); plan.PlanName = "Custom"; } else { int planid = UserPlans.GetPlanBySku(plan.SkuCount); plan.PlanName = Statics.GetEnumDescription((Statics.StripePlans)(planid)); plan.Price = UserPlans.GetPlanCost(planid); } } if (!String.IsNullOrWhiteSpace(SessionData.StripeCardId)) { ViewBag.IsCardAdded = true; } return(View(plan)); }
public ActionResult Index() { var userPlan = new UserPlan { AlgorithmList = new [] { new System.Web.Mvc.SelectListItem { Value = "0", Text = "Euklido" }, new System.Web.Mvc.SelectListItem { Value = "1", Text = "Manhatano" }, new System.Web.Mvc.SelectListItem { Value = "2", Text = "Čebyševo" } } }; return(View(userPlan)); }
public ActionResult AddUserPlan(UserPlan _userplan) { string msg; foreach (var objorganizationResult in _userplan.MultipleUserID) { _userplan.IsPlanApplied = false; _userplan.UserID = objorganizationResult; _userplan.UserPlanID = _planService.AddUserPlan(Mapper.Map <HCRGUniversityMgtApp.NEPService.PlanService.UserPlan>(_userplan)); } if (_userplan.UserPlanID != 0) { msg = GlobalConst.Message.UserPlanAdded; } else { msg = GlobalConst.Message.UserPlanExist; } return(Json(msg, GlobalConst.Message.text_html)); }
public async Task <string> Handle(AddNewUser request, CancellationToken cancellationToken) { var userPlans = new UserPlan[] { new UserPlan { PlanId = request.PlanId, Start = DateTime.Now } }; var result = _dbContext.Users.Add(new User { UserId = request.UserId, FirstName = request.FirstName, LastName = request.LastName, EmailAddress = request.EmailAddress, Created = DateTime.Now, UserPlans = userPlans, }); await _dbContext.SaveChangesAsync(cancellationToken); return(result.Entity.UserId); }
public ActionResult CalculateDistances(UserPlan userPlan) { var userPlanParams = new List <double> { userPlan.UserMinutes, userPlan.UserSms, userPlan.UserGb }; switch (userPlan.SelectedId) { case 0: ViewBag.DistanceName = "Euklido atstumo rezultatai"; return(View(_distanceCalculator.EuclideanDistance(_planRepository.Plans, userPlanParams))); case 1: ViewBag.DistanceName = "Manheteno atstumo rezultatai"; return(View(_distanceCalculator.ManhattanDistance(_planRepository.Plans, userPlanParams))); case 2: ViewBag.DistanceName = "Čebyševo atstumo rezultatai"; return(View(_distanceCalculator.ChebyshevDistance(_planRepository.Plans, userPlanParams))); default: return(View(_distanceCalculator.EuclideanDistance(_planRepository.Plans, userPlanParams))); } }
protected void WithdrawMoneyFromSystem_Click(object sender, System.EventArgs e) { if (MoneyInSystem == Money.Zero) { return; } try { UserPlan.TryToWidthdrawlMoneyFromSystem(); //SUCCESS WithdrawMoneyFromSystem.Visible = false; MoneyInSystemLabel.Text = string.Format("{0}: {1}", U6006.MONEYINSYSTEM, MoneyInSystem); SuccessPanel.Visible = true; SuccessTextLiteral.Text = U3501.TRANSFEROK; } catch (MsgException ex) { ErrorPanel.Visible = true; ErrorTextLiteral.Text = ex.Message; } }
public void InsertUserPlan(int loginid) { DataTable dtplantype = new DataTable(); objBL_Common = new BL_Common(); try { dtplantype = objBL_Common.plantypedetails("top 1 *", "EC_PlanType", "LOWER(PlanName)='FREE' and IsActive = 1 order by plandate desc"); if (dtplantype.Rows.Count > 0) { objUserPlan = new UserPlan(); objBL_UserPlan = new BL_UserPlan(); objUserPlan.FK_UserID = loginid; objUserPlan.FK_PlanID = Convert.ToInt32(dtplantype.Rows[0]["PK_PlanID"].ToString()); objUserPlan.ActiveFrom = DateTime.Now; objUserPlan.ActiveTo = DateTime.Now.AddMonths(1); objUserPlan.IsActive = true; objUserPlan.CreatedBy = loginid; objUserPlan.CreatedOn = DateTime.Now; objBL_UserPlan.AccessInsertUserPlan(objUserPlan); string[] UPtype = new string[3]; UPtype[0] = Convert.ToString(dtplantype.Rows[0]["IsSingleUser"]); UPtype[1] = Convert.ToString(dtplantype.Rows[0]["NOC"]); UPtype[2] = Convert.ToString(dtplantype.Rows[0]["AllowedMails"]); Session["lstUserPlanType"] = UPtype; objUserPlan = null; objBL_UserPlan = null; } } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("FreeAccountSignUp.aspx:InsertUserPlan() - " + ex.Message); } }
public static int Create(UserPlanDTO upCreate) { try { databaseDataContext db = new databaseDataContext(); UserPlan up = new UserPlan() { UserId = upCreate.UserId, PlanId = upCreate.PlanId }; db.UserPlans.InsertOnSubmit(up); db.SubmitChanges(); return(up.Id); } catch (Exception e) { Console.WriteLine(e.Message); } return(-1); }
public async Task <Document> UpsertPersonalizedPlanAsync(UserPlan userPlan) { try { PersonalizedPlanViewModel personalizedPlan = userPlan.PersonalizedPlan; string oId = userPlan.UserId; dynamic response = null; var userPersonalizedPlan = await GetPersonalizedPlanAsync(personalizedPlan.PersonalizedPlanId); if (userPersonalizedPlan == null || userPersonalizedPlan?.PersonalizedPlanId == Guid.Empty) { var newPlan = await backendDatabaseService.CreateItemAsync(personalizedPlan, cosmosDbSettings.ActionPlansCollectionId); if (!Guid.TryParse(newPlan.Id, out Guid guid)) { return(response); } response = newPlan; } else { response = await backendDatabaseService.UpdateItemAsync( personalizedPlan.PersonalizedPlanId.ToString(), personalizedPlan, cosmosDbSettings.ActionPlansCollectionId); } if (!userPlan.saveActionPlan) { await UpdatePlanToProfile(personalizedPlan.PersonalizedPlanId, oId, personalizedPlan); } return(response); } catch { return(null); } }
/// <summary> /// Created By :: Sakthivel.R /// Created On :: 15-9-2015 /// Comments :: Select all records for UserPlan details. /// </summary> #region Select_Records_CreateUserPlan public List <UserPlan> UserPlanSelect(int PK_UserPlanID) { objEmailCampDataContext = new EmailCampDataContext(); lstUserPlan = new List <UserPlan>(); var Select = (from cde in objEmailCampDataContext.spUserPlan_AllActions(PK_UserPlanID, null, null, null, null, true, null, null, null, null, "s") select cde).ToList(); if (Select.Count > 0) { lstUserPlan = new List <UserPlan>(); foreach (var item in Select) { objUserPlan = new UserPlan(); objUserPlan.ActiveFrom = item.ActiveFrom; objUserPlan.ActiveTo = item.ActiveTo; if (item.FK_PlanID != null) { objUserPlan.FK_PlanID = Convert.ToInt32(item.FK_PlanID); } objUserPlan.FK_UserID = item.FK_UserID; objUserPlan.IsActive = item.IsActive; objUserPlan.PK_UserPlanID = item.PK_UserPlanID; objUserPlan.CreatedOn = item.CreatedOn; objUserPlan.CreatedBy = item.CreatedBy; objUserPlan.UpdatedBy = item.UpdatedBy; objUserPlan.UpdatedOn = item.UpdatedOn; lstUserPlan.Add(objUserPlan); } } objEmailCampDataContext = null; objUserPlan = null; return(lstUserPlan); }
/// <summary> /// Initialize the backtest task packet. /// </summary> public BacktestNodePacket(int userId, int projectId, string sessionId, byte[] algorithmData, decimal startingCapital, string name, UserPlan userPlan = UserPlan.Free) : base(PacketType.BacktestNode) { UserId = userId; Algorithm = algorithmData; SessionId = sessionId; ProjectId = projectId; UserPlan = userPlan; Name = name; Language = Language.CSharp; }