public void GetFreeBerths_BerthsAmountEqualsTwo() { Berth berth1 = new Berth() { BerthId = 1, MarinaId = 1, Price = 300 }; Berth berth2 = new Berth() { BerthId = 2, MarinaId = 1, Price = 600 }; Berth berth3 = new Berth() { BerthId = 3, MarinaId = 1, Price = 500 }; Berth berth4 = new Berth() { BerthId = 4, MarinaId = 1, Price = 200 }; List <Berth> listOfBerths = new List <Berth>(); listOfBerths.Add(berth1); listOfBerths.Add(berth2); listOfBerths.Add(berth3); listOfBerths.Add(berth4); HashSet <int> reservedBerthsIds = new HashSet <int>(); reservedBerthsIds.Add(1); reservedBerthsIds.Add(2); Assert.AreEqual(2, Methods.getFreeBerths(listOfBerths, reservedBerthsIds).Count, "Amount of berths should be equal to 2"); }
public async Task <Berth> GetBerthByMarinaIdAndBerthId(int?marinaId, int?berthId) { var result = string.Empty; var berthResult = new Berth(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(this.berthServiceBase); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var urlAddress = berthServiceBase + "marinas" + "/" + marinaId + "/" + "berths" + "/" + berthId; HttpResponseMessage response = await client.GetAsync(urlAddress).ConfigureAwait(continueOnCapturedContext: false); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsStringAsync(); } try { berthResult = JsonConvert.DeserializeObject <Berth>(result); } catch (Exception e) { throw new Exception($"Error: {e.StackTrace}"); } } return(berthResult); }
public static BerthViewModel FromEntity(Berth entity) { return(new BerthViewModel { Id = entity.Id, Code = entity.Code, Name = entity.Name }); }
public IActionResult Create(int marinaId, double price) { Berth berth = new Berth() { MarinaId = marinaId, Price = price }; bookMarinaClient.CreateBerth(berth); return(RedirectToAction("Index", "Marina")); }
public async void CreateBerth(Berth berth) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(this.berthServiceBase); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var json = JsonConvert.SerializeObject(berth); HttpResponseMessage response = await client.PostAsync(berthServiceBase, new StringContent(json, Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); } }
public void CreateBerth(Berth berth) { try { using (MySqlConnection conn = GetConnection()) { conn.Open(); MySqlCommand cmd = new MySqlCommand(Queries.CreateBerth, conn); cmd.Parameters.Add("@marinaId", MySqlDbType.Int16).Value = berth.MarinaId; cmd.Parameters.Add("@price", MySqlDbType.Double).Value = berth.Price; cmd.ExecuteReader(); } } catch (Exception e) { } }
public static void Build() { Berth open = active.Berths[0]; bool openslot = false; foreach (Berth b in active.Berths) { if (!b.Full) { openslot = true; } } if (!openslot) { Debug.Log("No open slots"); return; } int i = 0; while (open.Full) { i++; open = active.Berths [i]; } Debug.Log("Open Berth is #" + open.Designation); GameObject s = Instantiate(ShipAbstract.ShipPrefabs[visual.value]); ShipAbstract sb = s.GetComponent <ShipAbstract> (); // player.empire.Ships.Add (sb.gameObject.GetComponent<Ship> ()); s.GetComponent <NavMeshAgent>().Warp(new Vector3(open.transform.position.x, .59f, open.transform.position.z)); s.transform.rotation = Quaternion.Inverse(open.transform.rotation); sb.faction = FAC.PLAYER; sb.shipClass.ImportDesign(ShipDesign.Designs[design.value]); // player.empire.Unassigned [0].NewCommand (sb.GetComponent<ShipClass> ()); // sb.Start (); Debug.Log("Ship built"); }
public Berth GetBerthByIdAndMarinaId(int marinaId, int berthId) { var berthById = new Berth(); using (MySqlConnection conn = GetConnection()) { conn.Open(); MySqlCommand cmd = new MySqlCommand(Queries.GetBerthByIdAndMarinaId, conn); cmd.Parameters.Add("@marinaId", MySqlDbType.Int16).Value = marinaId; cmd.Parameters.Add("@berthId", MySqlDbType.Int16).Value = berthId; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { berthById.BerthId = Convert.ToInt32(reader["BerthId"]); berthById.MarinaId = Convert.ToInt32(reader["MarinaId"]); berthById.Price = Convert.ToDouble(reader["Price"]); } } } return(berthById); }
public void Post([FromBody] Berth berth) { IBerthRepository repository = HttpContext.RequestServices.GetService(typeof(BerthRepository)) as BerthRepository; repository.CreateBerth(berth); }
void CreateBerth(Vector2 pos, float rotation, int col) { Berth b = new Berth(pos, rotation, col); berths.Add(b); }
public void ClearBerth() { berth = null; }
public void AssignToBerth(Berth b) { berth = b; }
public void EnsureSeedData() { try { if (!_context.Agent.Any()) { var Ag = new Agent() { Name = "Hakeem", Code = "001" }; _context.Agent.Add(Ag); Ag = new Agent() { Name = "Bayo", Code = "002" }; _context.Agent.Add(Ag); Ag = new Agent() { Name = "Janta", Code = "003" }; _context.Agent.Add(Ag); _context.SaveChanges(); } if (!_context.Berth.Any()) { var Be = new Berth() { Name = "NNPC", Code = "NN" }; _context.Berth.Add(Be); Be = new Berth() { Name = "NigerDock", Code = "NGR" }; _context.Berth.Add(Be); _context.SaveChanges(); } if (!_context.Inspector.Any()) { var Ins = new Inspector() { Name = "Abubakar Suleiman", Code = "I002" }; _context.Inspector.Add(Ins); Ins = new Inspector() { Name = "Emmanuel Iwu", Code = "I003" }; _context.Inspector.Add(Ins); _context.SaveChanges(); } if (!_context.Port.Any()) { var Pr = new Port() { Name = "Calabar", Code = "P002" }; _context.Port.Add(Pr); Pr = new Port() { Name = "Lagos", Code = "P003" }; _context.Port.Add(Pr); _context.SaveChanges(); } if (!_context.Vessel.Any()) { var Ve = new Vessel() { Name = "Voyager", Code = "V002" }; _context.Vessel.Add(Ve); Ve = new Vessel() { Name = "TORM FREYA", Code = "V003" }; _context.Vessel.Add(Ve); _context.SaveChanges(); } } catch (Exception ex) { throw ex; } }