// PUT: api/PoliceStations/5
        public async Task <IHttpActionResult> Put([FromODataUri] int key, PoliceStation policeStation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (key != policeStation.Id)
            {
                return(BadRequest());
            }

            db.Entry(policeStation).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PoliceStationExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(policeStation));
        }
        public async Task <ActionResult <PoliceStation> > PostPoliceStation(PoliceStation policeStation)
        {
            _context.policeStations.Add(policeStation);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPoliceStation", new { id = policeStation.Id }, policeStation));
        }
Esempio n. 3
0
 private void FillPoliceStationForEdit(PoliceStation policeStaion)
 {
     try
     {
         if (policeStaion != null)
         {
             txtName.Text = policeStaion.Name;
             txtCode.Text = policeStaion.Code.ToString();
             //ddlCountry.SelectedValue = policeStaion.CountryID.ToString();
             txtCountryName.Text = new CountryRT().GetCountryByIID(policeStaion.CountryID).Name;
             txtCountryID.Text   = policeStaion.CountryID.ToString();
             //ddlDivisionOrState.SelectedValue = policeStaion.DivisionOrStateID.ToString();
             txtDivOrStateName.Text = new DivisionOrStateRT().GetDivisionOrStateByID(policeStaion.DivisionOrStateID).Name;
             txtDivOrStateID.Text   = policeStaion.DivisionOrStateID.ToString();
             //ddlDistrict.SelectedValue = policeStaion.DistrictID.ToString();
             txtDistrictName.Text = new DistrictRT().GetDistrictByID(policeStaion.DistrictID).Name;
             txtDistrictID.Text   = policeStaion.DistrictID.ToString();
             chkIsRemovedPoliceStation.Checked = policeStaion.IsRemoved;
             Session[sessPoliceStation]        = policeStaion;
         }
     }
     catch (Exception ex)
     {
         labelMessage.Text      = "Error : " + ex.Message;
         labelMessage.ForeColor = System.Drawing.Color.Red;
     }
 }
Esempio n. 4
0
    // Use this for initialization
    void Start()
    {
        // Position offset based on mapSize
        offset = 0.5f - (mapSize / 2f);

        // Create placeGrid as new places
        placeGrid   = new IPlace[mapSize, mapSize];
        placeGOGrid = new GameObject[mapSize, mapSize];
        for (int y = 0; y < mapSize; y++)
        {
            for (int x = 0; x < mapSize; x++)
            {
                placeGrid[x, y] = new Apartment();
                if ((x + y) % 3 == 0)
                {
                    placeGrid[x, y] = new PizzaPlace();
                }
                if ((x - y) % 3 == 0)
                {
                    placeGrid[x, y] = new PoliceStation();
                }
                if ((x - y) % 3 == 0 && y < 7 && y > 2)
                {
                    placeGrid[x, y] = new Bank();
                }
                if (x % 3 == 0 || y == 2 || y == 7)
                {
                    placeGrid[x, y] = new Street();
                }
            }
        }
        UpdateMap();
    }
Esempio n. 5
0
 protected void lvPoliceStation_ItemCommand(object sender, ListViewCommandEventArgs e)
 {
     if (e.CommandName == "EditPoliceStation")
     {
         try
         {
             labelMessage.Text = string.Empty;
             chkIsRemovedPoliceStation.Visible = true;
             btnSave.Visible   = false;
             btnUpdate.Visible = true;
             //btnDelete.Visible = true;
             btnCancel.Visible = true;
             int policeStationID = Convert.ToInt32(e.CommandArgument);
             hdPoliceStationID.Value = policeStationID.ToString();
             using (PoliceStationRT receiverTransfer = new PoliceStationRT())
             {
                 PoliceStation policeStaion = receiverTransfer.GetPoliceStaionByID(policeStationID);
                 FillPoliceStationForEdit(policeStaion);
             }
         }
         catch (Exception ex)
         {
             labelMessage.Text      = "Error : " + ex.Message;
             labelMessage.ForeColor = System.Drawing.Color.Red;
         }
     }
 }
        public async Task <IActionResult> PutPoliceStation(int id, PoliceStation policeStation)
        {
            if (id != policeStation.Id)
            {
                return(BadRequest());
            }

            _context.Entry(policeStation).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PoliceStationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 7
0
        //Create a method for retrieving data
        public List <PoliceStation> GetAllPoliceStation()
        {
            SqlConnection con = new SqlConnection(connectionString);

            string     query = "SELECT * FROM PoliceStation";
            SqlCommand cmd   = new SqlCommand(query, con);

            con.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            List <PoliceStation> policeStations = new List <PoliceStation>();

            while (reader.Read())
            {
                PoliceStation policeStation = new PoliceStation();
                policeStation.PoliceStationId          = (int)reader["PoliceStationId"];
                policeStation.PoliceStationName        = reader["PoliceStationName"].ToString();
                policeStation.PoliceStationInformation = reader["PoliceStationInformation"].ToString();

                policeStations.Add(policeStation);
            }
            reader.Close();
            con.Close();
            return(policeStations);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PoliceStation policeStation = db.PoliceStations.Find(id);

            db.PoliceStations.Remove(policeStation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
 public void AddPoliceStaion(PoliceStation policeStaion)
 {
     try
     {
         DatabaseHelper.Insert <PoliceStation>(policeStaion);
     }
     catch (Exception ex) { throw new Exception(ex.Message, ex); }
 }
Esempio n. 10
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            PoliceStation policeStation = await db.PoliceStations.FindAsync(id);

            db.PoliceStations.Remove(policeStation);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 11
0
        //
        // GET: /PoliceStation/Details/5

        public ActionResult Details(int id = 0)
        {
            PoliceStation policestation = db.PoliceStations.Find(id);

            if (policestation == null)
            {
                return(HttpNotFound());
            }
            return(View(policestation));
        }
        public void Delete(int id)
        {
            var PoliceStation = new PoliceStation
            {
                PoliceStationId = id
            };

            unitOfWork.PoliceStationRepository.Delete(PoliceStation);
            unitOfWork.Save();
        }
Esempio n. 13
0
 public ActionResult Edit([Bind(Include = "Id,FechaAlta,Direccion,Altura,Partida,Barrio,Sede,Detalle,Latitud,Longitud,Enable")] PoliceStation policeStation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(policeStation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(policeStation));
 }
 public ActionResult Edit([Bind(Include = "Id,PoliceStationName,StartingDate,Address,Phone,Email,Fax,ComplaintRegistrationId")] PoliceStation policeStation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(policeStation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ComplaintRegistrationId = new SelectList(db.ComplaintRegistrations, "Id", "ComplainBy", policeStation.ComplaintRegistrationId);
     return(View(policeStation));
 }
Esempio n. 15
0
 public ActionResult EditPoliceStation([Bind(Include = "Id,DistrictId,PoliceStationCode,PoliceStationName")] PoliceStation policestation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(policestation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ViewAllPoliceSation"));
     }
     ViewBag.DistrictId = new SelectList(db.Districts, "Id", "DistrictName", policestation.DistrictId);
     return(View(policestation));
 }
        public void Create(PoliceStationViewModel PoliceStationViewModel)
        {
            var PoliceStation = new PoliceStation
            {
                PoliceStationName = PoliceStationViewModel.PoliceStationName,
                DistrictId        = PoliceStationViewModel.DistrictId
            };

            unitOfWork.PoliceStationRepository.Insert(PoliceStation);
            unitOfWork.Save();
        }
Esempio n. 17
0
        //метод генерирования полицейского участка и наполнения его людьми
        private PoliceStation GeneratePoliceStation()
        {
            PoliceStation   pStation = new PoliceStation();
            PoliceGenerator pg       = new PoliceGenerator();

            for (int i = 0; i < 5; i++)
            {
                pStation.workers.Add(pg.PoliceGenerate());
            }
            return(pStation);
        }
Esempio n. 18
0
 public ActionResult Edit(PoliceStation policestation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(policestation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "Name", policestation.DistrictId);
     ViewBag.CityId     = new SelectList(db.Cities, "CityId", "Name", policestation.CityId);
     return(View(policestation));
 }
Esempio n. 19
0
        //
        // GET: /PoliceStation/Edit/5

        public ActionResult Edit(int id = 0)
        {
            PoliceStation policestation = db.PoliceStations.Find(id);

            if (policestation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "Name", policestation.DistrictId);
            ViewBag.CityId     = new SelectList(db.Cities, "CityId", "Name", policestation.CityId);
            return(View(policestation));
        }
Esempio n. 20
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,AddressId")] PoliceStation policeStation)
        {
            if (ModelState.IsValid)
            {
                db.Entry(policeStation).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.AddressId = new SelectList(db.Addresses, "Id", "Id");
            return(View(policeStation));
        }
Esempio n. 21
0
        /// <summary>
        /// Method is triggerd when the user clicks on the stationButton for finding the nearest police station.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void onStationButton(object sender, EventArgs e)
        {
            //hier moet de functie om het dichtstbijzijnde politiebureau te vinden
            var location = await geo.GetLocationDouble();

            var policeStations = new PoliceStations();

            station = policeStations.GetNearestStation(location.Item1, location.Item2);

            label.Text = string.Format("Politiebureau: {0} \r\nAdres: {1}", station.Titel, station.BezoekAdres);
            navigateButton.IsVisible = true;
        }
Esempio n. 22
0
        public void UpdatePoliceStaion(PoliceStation policeStation)
        {
            try
            {
                OiiOHaatDCDataContext msDC      = DatabaseHelper.GetDataModelDataContext();
                PoliceStation         policeSta = msDC.PoliceStations.Single(d => d.IID == policeStation.IID);
                DatabaseHelper.Update <PoliceStation>(msDC, policeStation, policeSta);

                msDC.Dispose();
            }
            catch (Exception ex) { throw new Exception(ex.Message, ex); }
        }
        // POST: api/PoliceStations
        public async Task <IHttpActionResult> Post(PoliceStation policeStation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PoliceStations.Add(policeStation);
            await db.SaveChangesAsync();

            return(Created(policeStation));
        }
        public ActionResult Create([Bind(Include = "PoliceStationId,PoliceStationName,DistrictId")] PoliceStation policestation)
        {
            if (ModelState.IsValid)
            {
                db.PoliceStations.Add(policestation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "DistrictName", policestation.DistrictId);
            return(View(policestation));
        }
Esempio n. 25
0
 static public void ConfigureServices(string connectionString, IServiceCollection services)
 {
     services.AddDbContext <PoliceStationManagementDbContext>(options =>
                                                              options.UseSqlServer(connectionString))
     .AddTransient <EfPoliceStationManagementDbContext, PoliceStationManagementDbContext>()
     .AddTransient <IPoliceStationRepository, PoliceStationManagementRepository>()
     .AddTransient <IPoliceStationManagement, PoliceStationManagement>()
     .AddTransient <IPoliceStation, PoliceStation>((context) =>
     {
         PoliceStation entity = PoliceStation.CreatePoliceStation("Empty", "Empty", 0, "Empty");
         return(entity);
     });
 }
Esempio n. 26
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,AddressId")] PoliceStation policeStation)
        {
            if (ModelState.IsValid)
            {
                db.PoliceStations.Add(policeStation);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.AddressId = new SelectList(db.Addresses, "Id", "Id");
            return(View(policeStation));
        }
Esempio n. 27
0
        public PoliceStation GetPoliceStationByID(long?polceStatnID)
        {
            try
            {
                OiiOHaatDCDataContext dbContext     = DatabaseHelper.GetDataModelDataContext();
                PoliceStation         policeStation = new PoliceStation();
                policeStation = dbContext.PoliceStations.Single(d => d.IID == polceStatnID);

                dbContext.Dispose();
                return(policeStation);
            }
            catch (Exception ex) { throw new Exception(ex.Message, ex); }
        }
Esempio n. 28
0
        public ActionResult Create(PoliceStation policestation)
        {
            if (ModelState.IsValid)
            {
                db.PoliceStations.Add(policestation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "Name", policestation.DistrictId);
            ViewBag.CityId     = new SelectList(db.Cities, "CityId", "Name", policestation.CityId);
            return(View(policestation));
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            AssemblyMaster am = new AssemblyMaster();

            #region CityService
            am.PathCityService = @"\\dc\Студенты\ПКО\PMP-162.1\SmartCity\CityService.soap";

            CityService cs = new CityService();
            cs.CodeSrevice = 102;
            cs.NameService = "Полиция";

            //am.CreateCityService(cs);
            #endregion

            #region
            am.PathCity = @"\\dc\Студенты\ПКО\PMP-162.1\SmartCity\City.soap";

            City city = new City();
            city.Area         = 300629;
            city.Population   = 834813;
            city.CityName     = "Ақтөбе";
            city.CityServices = new List <CityService>()
            {
                cs
            };

            //am.CreateCity(city);
            #endregion

            #region Region
            am.PathRegion = @"\\dc\Студенты\ПКО\PMP-162.1\SmartCity\Region.soap";

            Region region = new Region();
            region.MainCity    = city;
            region.Population  = 834813;
            region.RegionCites = null;
            region.RegionName  = "Актюбинская область";

            //am.CreateRegion(region);
            #endregion

            MasterPolice pm = new MasterPolice();
            pm.PathPoliceStation = @"\\dc\Студенты\ПКО\PMP-162.1\SmartCity\PoliceStation.soap";
            PoliceStation ps = new PoliceStation();
            ps.Address           = "Темирязе 31";
            ps.city              = am.GetCity()[0];
            ps.CodePoliceStation = 001;
            ps.NamePoliceStation = "Темирязева";

            pm.CreatePoliceStation(ps);
        }
Esempio n. 30
0
        // GET: Address/PoliceStations/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PoliceStation policeStation = await db.PoliceStations.FindAsync(id);

            if (policeStation == null)
            {
                return(HttpNotFound());
            }
            return(View(policeStation));
        }
Esempio n. 31
0
    public string buildingFlavorText(string building)
    {
        if (building == "House")
        {
            House x = new House();
            return x.flavorText;
        }

        else if (building == "Farm")
        {
            Farm x = new Farm();
            return x.flavorText;
        }

        else if (building == "Factory")
        {
            Factory x = new Factory();
            return x.flavorText;
        }

        else if (building == "Executive Building")
        {
            ExecutiveBuilding x = new ExecutiveBuilding();
            return x.flavorText;
        }

        else if (building == "Educational Building")
        {
            EducationalBuilding x = new EducationalBuilding();
            return x.flavorText;
        }

        else if (building == "Hospital")
        {
            Hospital x = new Hospital();
            return x.flavorText;
        }

        else if (building == "Laboratory")
        {
            Laboratory x = new Laboratory();
            return x.flavorText;
        }

        else if (building == "Police Station")
        {
            PoliceStation x = new PoliceStation();
            return x.flavorText;
        }

        else if (building == "Workplace")
        {
            Workplace x = new Workplace();
            return x.flavorText;
        }

        else if (building == "Public Space")
        {
            PublicSpace x = new PublicSpace();
            return x.flavorText;
        }

        else if (building == "World Trade Center")
        {
            WTC x = new WTC();
            return x.flavorText;
        }

        else if (building == "Military Outpost")
        {
            MilitaryOutpost x = new MilitaryOutpost();
            return x.flavorText;
        }

        else if (building == "Food Territory")
        {
            FoodTerritory x = new FoodTerritory();
            return x.flavorText;
        }

        else if (building == "Materials Territory")
        {
            MaterialsTerritory x = new MaterialsTerritory();
            return x.flavorText;
        }

        else if (building == "Citizens Territory")
        {
            CitizensTerritory x = new CitizensTerritory();
            return x.flavorText;
        }

        else
            return "";
    }