public async Task DeleteExperience(ExperienceModel experienceModel) { if (null == experienceModel) { return; } // Sync with the database Experience experience = new Experience() { Id = experienceModel.Id, Name = experienceModel.Name, Description = experienceModel.Description, ExpressionSpeed = (byte)experienceModel.ExpressionSpeed, ExpressionSuction = (byte)experienceModel.ExpressionSuction, StimulationSpeed = (byte)experienceModel.StimulationSpeed, StimulationSuction = (byte)experienceModel.StimulationSuction, Breast = (byte)experienceModel.Breast, ExperienceId = (byte)experienceModel.ExperienceId, Duration = Convert.ToInt32(experienceModel.Duration.TotalSeconds), TransistionType = (byte)experienceModel.TransitionType, TransistionTime = Convert.ToInt32(experienceModel.TransitionTime.TotalSeconds), Storage = (byte)experienceModel.Storage, CreatedAt = experienceModel.CreatedAt }; await DataManager.Instance.DeleteUserExperience(experience); await DataManager.Instance.SyncUserExperiences(); await Sync(); }
public PartialViewResult ManageDetails(int id, int cpsId) { var model = ExperienceModel.GetExperienceDetails(id); ViewBag.cpsId = cpsId; return(PartialView(model)); }
public async Task <ExperienceModel> PutAsync(Guid id, [FromBody] ExperienceModel model) { var item = await _experienceQuery.Update(id, model); var resultModel = _mapper.Map <ExperienceModel>(item); return(resultModel); }
public ActionResult ExperienceInline_Update([DataSourceRequest] DataSourceRequest request, SchemeExperience experience) { ExperienceModel.UpdateExperienceDetails(experience); // var vm = SchemeModel.GetSchemeExperiences(experience.SchemeID); //return Json(vm.Experiences); return(Json(ModelState.ToDataSourceResult())); }
public PartialViewResult CreateNewStrategy(VariantNodeViewModel variant) { int newId = VariantModel.CreateVariant(variant); var vm = ExperienceModel.GetExperienceDetailsWithRules(variant.ExperienceID); vm.CreatedVariantId = newId; return(PartialView("ViewStrategies", vm)); }
/// <summary> /// Create the default experiences. This ensures that the experiences are available /// the first time a user starts the app even if they do not have a network connection. /// </summary> public void CreateDefaultExperiences() { ExperienceModel experienceModel; DateTimeOffset creationDate = DateTimeOffset.Parse("01/01/2015"); // These also exist on the database and changes on the database will overwrite these defaults. // We include them here in case the app is not online the first time it is used experienceModel = new ExperienceModel() { Id = "920bfda9-9bd0-4641-b644-415d8aed04ac", Name = "First Time Pumper", CreatedBy = "babyation", Description = "Experience the ease of this setting for anyone who is using a pump for the first time", ExpressionSpeed = 4, ExpressionSuction = 5, StimulationSpeed = 2, StimulationSuction = 3, Breast = BreastType.Both, ExperienceId = 128, Duration = TimeSpan.FromSeconds(1800), TransitionType = TransitionType.Timed, TransitionTime = TimeSpan.FromSeconds(120), CreatedAt = creationDate.AddSeconds(1) }; experienceModel.Edit += model => { OnEditExperience(model); }; experienceModel.IsNew = !_knownExperiences.Contains(experienceModel.Id); _presetExperiences.Add(experienceModel); _allExperiences.Add(experienceModel); experienceModel = new ExperienceModel() { Id = "920bfda9-9bd0-4641-b644-415d8aed04ad", Name = "Power Pumping", CreatedBy = "babyation", Description = "Use this setting to help increase your milkflow", ExpressionSpeed = 5, ExpressionSuction = 4, StimulationSpeed = 1, StimulationSuction = 2, Breast = BreastType.Both, ExperienceId = 129, Duration = TimeSpan.FromSeconds(1800), TransitionType = TransitionType.Timed, TransitionTime = TimeSpan.FromSeconds(120), CreatedAt = creationDate.AddSeconds(2) }; experienceModel.Edit += model => { OnEditExperience(model); }; experienceModel.IsNew = !_knownExperiences.Contains(experienceModel.Id); _presetExperiences.Add(experienceModel); _allExperiences.Add(experienceModel); CurrentExperience = _presetExperiences[0]; }
public PartialViewResult CreateNewExperience(ExperienceNodeViewModel experience) { int newId = ExperienceModel.CreateExperience(experience); var vm = SchemeModel.GetSchemeExperiences(experience.SchemeID); vm.CreatedExperienceId = newId; vm.CreatedExperienceName = experience.Name; return(PartialView("ViewExperiences", vm)); }
/// <summary> /// Called when the front end begins editing an experience /// </summary> /// <param name="exp">The experience being edited</param> private void OnEditExperience(ExperienceModel exp) { bool newGuid = _presetExperiences.Contains(exp); exp = exp.Clone(newGuid); exp.IsSelected = false; exp.CreatedBy = "me"; exp.Edit += model => { OnEditExperience(model); }; EditExperience?.Invoke(exp); }
public void ContinuePumping() { ExperienceModel experience; // If we have not started a session and a pump is connected if ((_sessionModel == null) && (_pumpManager.ConnectedPump != null)) { DateTime startTime = DateTime.UtcNow; _pumpModel = _pumpManager.ConnectedPump; _isPaused = (_pumpModel.ActualState == PumpState.Pause) ? true : false; _durationSeconds = Convert.ToInt32(_pumpModel.CurrentDuration.TotalSeconds); _timerActive = false; experience = ExperienceManager.Instance.GetFromExperienceId(_pumpModel.DesiredExperience); if (experience != null) { _currentExperience = experience; } else { _currentExperience = ExperienceManager.Instance.CurrentExperience; } _sessionModel = new SessionModel() { StartTime = startTime, LeftBreastStartTime = startTime, RightBreastStartTime = startTime, SessionType = SessionType.Pump, CurrentExperience = _currentExperience, PumpPhase = (_pumpModel.ActualPumpingMode == PumpMode.Stimulation) ? PumpPhase.Stimulation : PumpPhase.Expression, Storage = _currentExperience.Storage }; _pumpModel.Storage = StorageType.Unspecified; _sessionModel.PropertyChanged -= _sessionModel_PropertyChanged; _pumpModel.PropertyChanged -= _pumpModel_PropertyChanged; _sessionModel.PropertyChanged += _sessionModel_PropertyChanged; _pumpModel.PropertyChanged += _pumpModel_PropertyChanged; //_pumpModel.DesiredExperience = _currentExperience.ExperienceId; //_pumpModel.DesiredPumpingMode = PumpMode.ExperienceControlled; _sessionModel.DesiredSpeed = _pumpModel.DesiredSpeed; _sessionModel.DesiredSuction = _pumpModel.DesiredSuction; _sessionModel.ActualSpeed = _pumpModel.ActualSpeed; _sessionModel.ActualSuction = _pumpModel.ActualSuction; //_sessionModel.Duration = _pumpModel.CurrentDuration; _sessionModel.ActualState = _pumpModel.ActualState; //_pumpModel.DesiredState = PumpState.Start; _sessionActive = true; } }
public IHttpActionResult PostExperience([FromBody] ExperienceModel model) { try { service.Insert(model.Technology, model.TimeExperience, model.DetailExperience); return(Created("Experiencia inserida", service.Get())); } catch (Exception ex) { return(InternalServerError(ex)); } }
public ActionResult InsertExperience(ExperienceModel model) { try { service.Insert(model.Technology, model.TimeExperience, model.DetailExperience); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Message = "Error: " + ex.Message; return(View(model)); } }
//[ValidateAntiForgeryToken] public async Task <IActionResult> Edit(ExperienceModel model) { if (!ModelState.IsValid) { return(View(model)); } return(await _resiliencyHelper.ExecuteResilient <IActionResult>(async() => { await _experienceWebApi.Update(model.Id, model); return RedirectToAction("Index"); }, View("Offline"))); }
public ActionResult Experience(ExperienceModel modelData) { if (!ModelState.IsValid) { return(View()); } modelData.UserId = _userId; var entityData = ModelToEntityMapper.ConvertToEntity <TblExperience, ExperienceModel>(modelData); var repo = new Repository <TblExperience>(new DatabaseEntities()); repo.Update(entityData); return(RedirectToAction("Index", "PrivateArea")); }
public void AddXp(int xpamt) { XP += xpamt; ExperienceModel mode = new ExperienceModel(); // Experience model handles leveling up // the loop runs until the unit no longer has enough xp to level up // while (mode.LeveledUp(this)) { LevelUp(); } }
public async Task <ExperienceEntity> Update(Guid id, ExperienceModel model) { var experience = GetQuery().FirstOrDefault(b => b.Id == id); if (experience == null) { throw new NotFoundException("Experience not found"); } //booking.BookingStatusCode = model.BookingStatusCode; await _uniOfWork.CommitAsync(); return(experience); }
public PartialViewResult GetDecisionContent(int experienceID, int strategyID) { var exp = ExperienceModel.GetExperienceStrategies(experienceID).FirstOrDefault(x => x.StrategyID == strategyID); var str = Models.VariantModel.GetVariantSlotString(strategyID); var model = new ExperienceStrategyDecisionPlan() { NumberOfItems = (exp != null ? exp.NumberOfItems : null), MinItems = (exp != null ? exp.MinItemsReturned : null), BreakOnMinItems = (exp != null ? exp.BreakOnMinItemsReturned : null), SlotInfo = str }; return(PartialView("DecisionPlanFooter", model)); }
/// <summary> /// Save changes to a user or preset experience. /// </summary> /// <remarks> /// Note that this may change the UserExperiences and PresetExperiences list items. In general /// a new experience will be added to the UserExperiences list, and a preset experience will /// be moved to the UserExperiences list if it is edited. /// </remarks> /// <param name="experience"></param> public async void Save(ExperienceModel experienceModel) { var existingExperience = _userExperiences.FirstOrDefault(e => e.Id == experienceModel.Id); if (existingExperience == null) { // Add the new experience experienceModel.IsNew = true; _userExperiences.Add(experienceModel); _allExperiences.Add(experienceModel); ExperienceAddedEvent?.Invoke(this, new ExperienceAddedEventArgs() { Id = experienceModel.Id }); } else { // Copy the changes in existingExperience.Copy(experienceModel); ExperienceChangedEvent?.Invoke(this, new ExperienceChangedEventArgs() { Id = experienceModel.Id }); } // Sync with the database Experience experience = new Experience() { Id = experienceModel.Id, Name = experienceModel.Name, Description = experienceModel.Description, ExpressionSpeed = (byte)experienceModel.ExpressionSpeed, ExpressionSuction = (byte)experienceModel.ExpressionSuction, StimulationSpeed = (byte)experienceModel.StimulationSpeed, StimulationSuction = (byte)experienceModel.StimulationSuction, Breast = (byte)experienceModel.Breast, ExperienceId = (byte)experienceModel.ExperienceId, Duration = Convert.ToInt32(experienceModel.Duration.TotalSeconds), TransistionType = (byte)experienceModel.TransitionType, TransistionTime = Convert.ToInt32(experienceModel.TransitionTime.TotalSeconds), Storage = (byte)experienceModel.Storage, CreatedAt = experienceModel.CreatedAt }; await DataManager.Instance.AddUserExperience(experience); EditingExperience = null; }
public async Task <ExperienceModel> PostAsync([FromBody] ExperienceModel model) { var item = await _experienceQuery.Create(model); var resultModel = _mapper.Map <ExperienceModel>(item); if (model.Images != null) { foreach (var image in model.Images) { image.ExperienceEntityId = resultModel.Id; var img = await this._experienceImageQueryProcessor.Create(image); } } return(resultModel); }
public IActionResult Post([FromBody] ExperienceModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = model.ToEntity(); entity.Id = 0; _experienceService.Insert(entity); //locales UpdateLocales(entity, model); return(NoContent()); }
/// <summary> /// Create an experience and fill out the default values /// </summary> /// <returns>A default experience</returns> public ExperienceModel Create() { var em = new ExperienceModel(); em.Id = Guid.NewGuid().ToString(); em.CreatedBy = "me"; em.TransitionType = TransitionType.Timed; em.TransitionTime = TimeSpan.FromMinutes(2); em.Duration = TimeSpan.FromMinutes(30); em.ExperienceId = _nextUserExperienceId; em.Edit += model => { OnEditExperience(model); }; em.CreatedAt = DateTimeOffset.UtcNow; _nextUserExperienceId++; return(em); }
public ActionResult Put(int id, [FromBody] ExperienceModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = _experienceService.GetById(model.Id); entity = model.ToEntity(entity); _experienceService.Update(entity); //locales UpdateLocales(entity, model); return(NoContent()); }
public JsonResult UpdateVariantAction(string variantList, string actionStatus, string experienceID) { switch (actionStatus) { case "Move Up": case "Move Down": VariantModel.UpdateVariantListPriority(variantList, actionStatus); break; default: VariantModel.UpdateVariantStatus(variantList, actionStatus); break; } // pass list back so we can rebind grid var m = ExperienceModel.GetExperienceStrategies(int.Parse(experienceID)); return(Json(new { strategies = m }, JsonRequestBehavior.AllowGet)); }
protected void UpdateLocales(Experience entity, ExperienceModel model) { foreach (var localized in model.Locales) { _localizedEnitityHelperService.SaveLocalizedValue(entity, x => x.Name, localized.Name, localized.LanguageId); _localizedEnitityHelperService.SaveLocalizedValue(entity, x => x.Period, localized.Period, localized.LanguageId); _localizedEnitityHelperService.SaveLocalizedValue(entity, x => x.Function, localized.Function, localized.LanguageId); _localizedEnitityHelperService.SaveLocalizedValue(entity, x => x.Tasks, localized.Tasks, localized.LanguageId); } }
public async Task <ExperienceEntity> Create(ExperienceModel model) { var experience = new ExperienceEntity { Id = Guid.NewGuid(), Name = model.Name, Description = model.Description, Price = model.Price, PriceOnSpecial = model.PriceOnSpecial, OnSpecialStartDate = model.OnSpecialStartDate, OnSpecialEndDate = model.OnSpecialEndDate, CreateDate = DateTime.UtcNow.ToLocalTime(), CreateUserId = _securityContext.UserEntity.Id.ToString(), ModifyDate = DateTime.UtcNow.ToLocalTime(), ModifyUserId = _securityContext.UserEntity.Id.ToString(), IsDeleted = false, StatusId = 1 }; _uniOfWork.Add(experience); await _uniOfWork.CommitAsync(); return(experience); }
public ActionResult SettingExperience(SettingExperiencePostViewModel model) { var repo = new Repository<ExperienceModel>(DbCollection.Experience); var repoEmployment = new Repository<ExperienceEmploymentModel>(DbCollection.ExperienceEmployment); #region Experience var experience = repo.Gets().FirstOrDefault(m => m.UserId.Equals(User.Identity.GetUserId())); if (experience != null) { experience.Occupation = model.Experience.Occupation; experience.Skill = model.Experience.Skill; repo.Update(experience); } else { experience = new ExperienceModel { UserId = User.Identity.GetUserId(), Occupation = model.Experience.Occupation, Skill = model.Experience.Skill }; repo.Insert(experience); } #endregion if (model.ListExperienceEmployment != null) { foreach (var item in model.ListExperienceEmployment) { item.UserId = User.Identity.GetUserId(); if (item.Id != new ObjectId("000000000000000000000000")) { repoEmployment.Update(item); } else { repoEmployment.Insert(item); } } } // Delete if (!string.IsNullOrEmpty(model.Delete)) { var listStrLineElements = model.Delete.Split(';').ToList(); foreach (var itemDetail in listStrLineElements) { repoEmployment.Delete(MyConstants.ConvertToObjectId(itemDetail)); } } // Update ShareSetting var repoShare = new Repository<ShareSettingModel>(DbCollection.ShareSetting); var share = repoShare.Gets().First(m => m.UserId.Equals(User.Identity.GetUserId())); share.Occupation = model.ShareSetting.Occupation; share.Skill = model.ShareSetting.Skill; share.Employment = model.ShareSetting.Employment; repoShare.Update(share); return Json(new { result = true, model }); }
public PartialViewResult ViewModifiers(int id) { var model = ExperienceModel.GetExperienceBoosts(id); return(PartialView(model)); }
public void ManageDetails(ExperienceNodeViewModel details) { ExperienceModel.UpdateExperienceDetails(details); }
/// <summary> /// Sync the ExperienceManager with the cloud /// </summary> /// <returns>System.Threading.Tasks.Task</returns> public async Task Sync() { ExperienceModel experienceModel; DataManager dataManager = DataManager.Instance; IEnumerable <Experience> experiences; bool isNew; try { DetermineKnownExperiences(); experiences = await dataManager.GetPresetExperiences(); if (experiences.Any()) { foreach (Experience experience in experiences) { isNew = !_knownExperiences.Contains(experience.Id); experienceModel = new ExperienceModel() { Id = experience.Id, Name = experience.Name, CreatedBy = "babyation", Description = experience.Description, ExpressionSpeed = experience.ExpressionSpeed, ExpressionSuction = experience.ExpressionSuction, StimulationSpeed = experience.StimulationSpeed, StimulationSuction = experience.StimulationSuction, Breast = (BreastType)experience.Breast, IsNew = isNew, ExperienceId = experience.ExperienceId, Duration = TimeSpan.FromSeconds(experience.Duration), TransitionType = (TransitionType)experience.TransistionType, TransitionTime = TimeSpan.FromSeconds(experience.TransistionTime), Storage = (StorageType)experience.Storage, CreatedAt = experience.CreatedAt }; var existing = _allExperiences.Where(e => e.Id == experience.Id).FirstOrDefault(); if (existing == null) { _presetExperiences.Add(experienceModel); _allExperiences.Add(experienceModel); experienceModel.Edit += model => { OnEditExperience(model); }; if (isNew) { _newExperiences.Add(experience.Id); } } else { existing.Copy(experienceModel); } } } experiences = await dataManager.GetUserExperiences(); if (experiences.Any()) { foreach (Experience experience in experiences) { isNew = !_knownExperiences.Contains(experience.Id); experienceModel = new ExperienceModel() { Id = experience.Id, Name = experience.Name, CreatedBy = "me", Description = experience.Description, ExpressionSpeed = experience.ExpressionSpeed, ExpressionSuction = experience.ExpressionSuction, StimulationSpeed = experience.StimulationSpeed, StimulationSuction = experience.StimulationSuction, Breast = (BreastType)experience.Breast, IsNew = isNew, ExperienceId = experience.ExperienceId, Duration = TimeSpan.FromSeconds(experience.Duration), TransitionType = (TransitionType)experience.TransistionType, TransitionTime = TimeSpan.FromSeconds(experience.TransistionTime), CreatedAt = experience.CreatedAt }; var existing = _allExperiences.Where(e => e.Id == experience.Id).FirstOrDefault(); if (existing == null) { _userExperiences.Add(experienceModel); _allExperiences.Add(experienceModel); experienceModel.Edit += model => { OnEditExperience(model); }; if (isNew) { _newExperiences.Add(experience.Id); } } else { existing.Copy(experienceModel); } if (experienceModel.ExperienceId > _nextUserExperienceId) { _nextUserExperienceId = experienceModel.ExperienceId + 1; } } } if (_newExperiences.Count > 0) { SyncKnownExperiences(); } if (CurrentExperience == null) { if (_presetExperiences.Count > 0) { CurrentExperience = _presetExperiences[0]; } } } catch (Exception ex) { } }
public PartialViewResult ViewDetails(int id) { var model = ExperienceModel.GetExperienceDetails(id); return(PartialView(model)); }
public ActionResult HierarchyBinding_Experiences(int experienceID, [DataSourceRequest] DataSourceRequest request) { List <ExperienceStrategy> strategies = ExperienceModel.GetExperienceStrategies(experienceID); return(Json(strategies.ToDataSourceResult(request))); }
public JsonResult UpdateExperienceModifiers(int experienceId, int pool, int profile) { var model = ExperienceModel.UpdateExperienceModifiers(experienceId, pool, profile); return(Json(model)); }