/** * Constructor for PatientInfoManager */ public PatientInfoManager(FileManager fileManager, EyeDoc db, AdvantageModel dbCon) { this.fileManager = fileManager; this.db = db; this.dbContext = dbCon; }
public Advantage(AdvantageModel model) { Name = model.Name.Trim(); Description = model.Description.Trim(); Cost = model.Cost; Skillable = model.Skillable ? 1 : 0; }
public ActiveListedAdvantage(AdvantageModel advantage) { AdvantageModel = advantage; TotalPoint = AdvantageModel.PtCostPerLvl; RankLevel = 1; IncAdvantageRankCommand = new DelegateCommand(x => IncRankExecute(), x => IncRankCanExecute()); DecAdvantageRankCommand = new DelegateCommand(x => DecRankExecute(), x => DecRankCanExecute()); }
private Advantage GetOrCreateAdvantage(AdvantageModel model) { var dbItem = _dataContext.Advantages.FirstOrDefault(i => i.Name == model.Name); if (dbItem == null) { dbItem = new Advantage(model); _dataContext.Advantages.Add(dbItem); _dataContext.SaveChanges(); } return(dbItem); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); this.dbContext = ContextFactory.GetContextPerRequest(); fileManager.setDBContext(this.dbContext); patientManager = new PatientInfoManager(fileManager, db, dbContext); patientManager.setData(data); patientManager.setPropertyFile(System.Configuration.ConfigurationManager.AppSettings["PropertyFile"]); utilManager = new UtilManager(data); ViewBag.BasePath = System.Configuration.ConfigurationManager.AppSettings["SiteName"]; ViewBag.HostName = System.Environment.MachineName; }
public AdvantageModel Put([FromBody] AdvantageModel model, long characterId) { var item = _dataContext.Advantages.First(item => item.Id == model.Id); var dbItem = new Advantage(model) { Id = model.Id }; _dataContext.Entry(item).CurrentValues.SetValues(dbItem); _dataContext.CharacterAdvantageAssociations .First(caa => caa.AdvantageFk == model.Id && caa.CharacterFk == characterId) .Level = model.Level; _dataContext.SaveChanges(); return(new AdvantageModel(item)); }
public static AdvantageModel GetContextPerRequest() { HttpContext httpContext = HttpContext.Current; if (httpContext == null) { return new AdvantageModel(); } else { AdvantageModel context = httpContext.Items[contextKey] as AdvantageModel; if (context == null) { context = new AdvantageModel(); httpContext.Items[contextKey] = context; } return context; } }
public AdvantageModel Post([FromBody] AdvantageModel model, long characterId) { using var transaction = _dataContext.Database.BeginTransaction(); var dbItem = GetOrCreateAdvantage(model); if (_dataContext.CharacterAdvantageAssociations.Any(csa => csa.CharacterFk == characterId && csa.AdvantageFk == dbItem.Id)) { throw new Exception("Only one Skill of a given type is allowed."); } var characterAdvantageAssociation = new CharacterAdvantageAssociation() { CharacterFk = characterId, AdvantageFk = dbItem.Id, Level = model.Level }; _dataContext.CharacterAdvantageAssociations.Add(characterAdvantageAssociation); _dataContext.SaveChanges(); transaction.Commit(); return(new AdvantageModel(dbItem) { Level = characterAdvantageAssociation.Level }); }
public void setDBContext(AdvantageModel dbContext) { this.dbContext = dbContext; }
public void InvokeSelectedAdvantageChanged(AdvantageModel model) => OnAdvantageSelected?.Invoke(model);