public AddCalamityView(Window _Owner, Calamity _OldCalamity) { InitializeComponent(); this.Owner = _Owner; this.Title = string.Format("Editing calamity for {0}", _OldCalamity.Device.Name); this.NewCalamity = _OldCalamity; this.bt_Accept.Click -= bt_AcceptAdd_Click; this.bt_Accept.Click += bt_AcceptEdit_Click; if (!string.IsNullOrEmpty(_OldCalamity.About)) { this.rtb_Description.Document = XamlReader.Parse(_OldCalamity.About) as FlowDocument; } this.dp_Date.SelectedDate = _OldCalamity.Date; if (_OldCalamity.IsSolved) { this.dp_Date.DisplayDateEnd = _OldCalamity.IsSolvedDate; } else { this.dp_Date.DisplayDateEnd = today; } }
public async Task <IActionResult> PutCalamity(int id, Calamity calamity) { if (id != calamity.CalamityId) { return(BadRequest()); } _context.Entry(calamity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CalamityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public bool CreateCalamity(CalamityViewDTO calamity) { bool check = false; if (calamity != null) { Calamity calamityModel = new Calamity() { //CalamityId = calamity.CalamityId, CalamityName = calamity.CalamityName, Description = calamity.Description, Location = calamity.Location, StartTime = calamity.StartTime, EndTime = calamity.EndTime, NumberOfFilming = calamity.NumberOfFilming, RoleSpecification = calamity.RoleSpecification, Status = calamity.Status, IsActive = true, }; _unitOfWork.GetRepository <Calamity>().Insert(calamityModel); _unitOfWork.Commit(); check = true; } return(check); }
public async Task <ActionResult <Calamity> > PostCalamity(Calamity calamity) { _context.Calamity.Add(calamity); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCalamity", new { id = calamity.CalamityId }, calamity)); }
private void CalamityIsSolvedChanged(object sender, RoutedEventArgs e) { // Get clicked Calamity from DataGridList Calamity c = (Calamity)this.dg_CalamityList.SelectedItem; // Cast sender to checkbox CheckBox cb = (CheckBox)sender; c.IsSolved = cb.IsChecked.Value; if (c.IsSolved) { SolveCalamityView scv = new SolveCalamityView(this, c); if (scv.ShowDialog() == true) { c.IsSolvedDate = scv.Calamity.IsSolvedDate; c.IsSolvedSolution = scv.Calamity.IsSolvedSolution; } else { return; } } else { c.IsSolvedDate = null; c.IsSolvedSolution = null; } DatabaseController.EditCalamity(c); // Update view UpdateCalamityListView(); }
private void InfoCalamity(object sender, RoutedEventArgs e) { // Get clicked Calamity from DataGridList Calamity c = (Calamity)this.dg_CalamityList.SelectedItem; CalamityView cv = new CalamityView(this, c); cv.ShowDialog(); }
private void CalamityBoost(Player player, ref int buffIndex) { Calamity.GetBuff("Cadence").Update(player, ref buffIndex); Calamity.GetBuff("YharimPower").Update(player, ref buffIndex); Calamity.GetBuff("TitanScale").Update(player, ref buffIndex); Calamity.GetBuff("FabsolVodkaBuff").Update(player, ref buffIndex); Calamity.GetBuff("Soaring").Update(player, ref buffIndex); Calamity.GetBuff("BoundingBuff").Update(player, ref buffIndex); }
public IActionResult GetCalamity(int id) { Calamity calamity = _calamityLogic.GetCalamityById(id); if (calamity == null) { return(NotFound("Calamity is not found")); } return(Ok(calamity)); }
public IActionResult UpdateCalamity([FromBody] Calamity calamity) { if (calamity == null) { return(BadRequest()); } bool check = _calamityLogic.UpdateCalamity(calamity); return(Ok(calamity)); }
public IActionResult DeleteCalamity(int id) { Calamity calamity = _calamityLogic.GetCalamityById(id); var check = _calamityLogic.DeleteCalamity(id); if (!check) { return(BadRequest("Error: Remove Fail")); } return(Ok(calamity)); }
public static void DeleteCalamity(int _CalamityId) { using (DatabaseContext dc = new DatabaseContext()) { Calamity d = dc.Calamities.Find(_CalamityId); dc.Entry(d).State = EntityState.Deleted; dc.SaveChanges(); } AddLog("Deleted Calamity"); }
public bool UpdateCalamity(Calamity calamity) { bool check = false; if (calamity != null) { _unitOfWork.GetRepository <Calamity>().Update(calamity); _unitOfWork.Commit(); check = true; } return(check); }
private void bt_AcceptAdd_Click(object sender, RoutedEventArgs e) { if (this.dp_Date.SelectedDate != null && this.dp_Date.SelectedDate <= DateTime.Now) { string about = RichTextBoxController.ConvertFlowDocumentToString(rtb_Description.Document); this.NewCalamity = new Calamity(about, this.dp_Date.SelectedDate.Value); this.DialogResult = true; } else { MessageBox.Show("Select a valid date"); } }
private void DeleteCalamity(object sender, RoutedEventArgs e) { Calamity c = (Calamity)this.dg_CalamityList.SelectedItem; if (MessageBox.Show(string.Format("Are you sure you want to delete calamity from {0}?", c.Device.Name), string.Format("Deleting calamity {0}", c.About), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { DatabaseController.DeleteCalamity(c.CalamityId); UpdateCalamityListView(); UpdateDeviceListView(); UpdateLogbookView(); liveChartsController.UpdateDistinctYears(); } }
public bool DeleteCalamity(int id) { bool check = false; Calamity calamity = _unitOfWork.GetRepository <Calamity>().FindById(id); if (calamity != null) { calamity.IsActive = false; _unitOfWork.GetRepository <Calamity>().Update(calamity); _unitOfWork.Commit(); check = true; } return(check); }
private void EditCalamity(object sender, RoutedEventArgs e) { Calamity d = (Calamity)this.dg_CalamityList.SelectedItem; AddCalamityView acv = new AddCalamityView(this, d); if (acv.ShowDialog() == true) { DatabaseController.EditCalamity(acv.NewCalamity); UpdateDeviceListView(); UpdateCalamityListView(); UpdateLogbookView(); liveChartsController.UpdateDistinctYears(); } }
public async Task <ActionResult <Calamity> > GetCalamity(int id) { Calamity calamity = await _context.Calamity .Include(c => c.CalamityCharacters) .ThenInclude(cc => cc.Character.User) .Include(c => c.CalamityEquipment) .ThenInclude(ce => ce.Equipment) .Where(c => c.CalamityId == id).FirstOrDefaultAsync(); if (calamity == null) { return(NotFound()); } return(calamity); }
public SolveCalamityView(Window _Owner, Calamity _Calamity) { this.Owner = _Owner; InitializeComponent(); this.Calamity = _Calamity; this.dp_Date.SelectedDate = DateTime.Today; DateTime d = Calamity.Date; this.dp_Date.DisplayDateStart = d; this.DataContext = Calamity; }
public static void EditCalamity(Calamity _EditedCalamity) { using (DatabaseContext dc = new DatabaseContext()) { Calamity d = dc.Calamities.Find(_EditedCalamity.CalamityId); d.About = _EditedCalamity.About; d.Date = _EditedCalamity.Date; d.IsSolved = _EditedCalamity.IsSolved; d.IsSolvedDate = _EditedCalamity.IsSolvedDate; d.IsSolvedSolution = _EditedCalamity.IsSolvedSolution; dc.Entry(d).State = EntityState.Modified; dc.SaveChanges(); } AddLog("Edited Calamity"); }
public static void AddCalamity(int _DeviceId, Calamity _Calamity) { using (DatabaseContext dc = new DatabaseContext()) { Device d = dc.Devices.Include("CalamityCollection").FirstOrDefault(e => e.DeviceId == _DeviceId); if (d != null) { d.CalamityCollection.Add(_Calamity); dc.Entry(d).State = EntityState.Modified; dc.SaveChanges(); AddLog("Added Calamity"); } } }
void Start() { level = PlayerPrefs.GetInt("LevelSelected"); levelManager = new CalamityManager(); calamities = levelManager.GetLevel(level).Calamities.ToArray(); firstCalamity = calamities[0]; calamityName = firstCalamity.Name; //calamityTimeRemaining = firstCalamity.TimeOfArrival; calamityTimeRemaining = 30; calamityTimeToComplete = firstCalamity.Duration; //calamityTimeToComplete = 10; originalCtc = calamityTimeToComplete; //ResultsWindow.SetActive (false); //instantiate calamity }
public List <Calamity> GetCalamities(int level) { Debug.Log("Getting Calamities"); IDbCommand dbCmd; IDataReader reader; dbConn = dsc.GetInstance(); dbConn.Open(); dbCmd = dbConn.CreateCommand(); dbCmd.CommandText = "SELECT b.name AS 'CalamityName', a.forecast AS 'Forecast', " + "a.duration AS 'CalamityDuration', a.time AS 'CalamityTimeOfArrival', " + "a.casualty_people AS 'CasualtyPeople', a.casualty_crops " + "AS 'CasualtyCrops' FROM lev_cal a JOIN calamity b ON a.cal_id = b.id " + "WHERE a.lev_id =" + level; reader = dbCmd.ExecuteReader(); string name = ""; string forecast = ""; int duration = 0; int time = 0; int casualtyPeople = 0; int casualtyCrops = 0; List <Calamity> calamities = new List <Calamity>(); while (reader.Read()) { name = reader.GetString(0); forecast = reader.GetString(1); duration = reader.GetInt16(2); time = reader.GetInt16(3); casualtyPeople = reader.GetInt16(4); casualtyCrops = reader.GetInt16(5); Calamity calamity = new Calamity(name, forecast, duration, time, casualtyPeople, casualtyCrops); calamities.Add(calamity); } dbConn.Close(); //return new Level(location, description); return(calamities); }
public void EventPicker() { eventActive = true; Debug.Log("hit condition"); curTime = 0.0f; //Picks a random event via index System.Random rand = new System.Random(); int indexToRemove = rand.Next(0, Events.Count); //Calls the given event based on the index of the event Calamity evnt = Events[indexToRemove]; evnt.proc(); Debug.Log("end of event"); //Removes the event //Events.RemoveAt(indexToRemove); }
public CalamityView(Window _Owner, Calamity _Calamity) { this.Owner = _Owner; InitializeComponent(); this.calamity = _Calamity; //https://msdn.microsoft.com/en-us/library/system.string.isnullorempty(v=vs.110).aspx if (!string.IsNullOrEmpty(this.calamity.IsSolvedSolution)) { this.rtb_Solution.Document = RichTextBoxController.ConvertStringToFlowDocument(this.calamity.IsSolvedSolution); } if (!string.IsNullOrEmpty(this.calamity.About)) { this.rtb_About.Document = RichTextBoxController.ConvertStringToFlowDocument(this.calamity.About); } //if (this.calamity.IsSolvedDate != null) // this.lbl_Solved.Content = this.calamity.IsSolvedDate.Value.ToString("dd-MM-yyyy"); DataContext = calamity; }
public Calamity GetCalamityById(int id) { Calamity calamity = _unitOfWork.GetRepository <Calamity>().FindById(id); return(calamity); }