Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PutMissingPerson(int id, MissingPerson missingPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != missingPerson.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public ActionResult AddMissingPerson([Bind(Exclude = "ImagePath")] MissingPerson missingPerson)
        {
            if (ModelState.IsValid == true)
            {
                string FileName      = Path.GetFileNameWithoutExtension(missingPerson.ImageFile.FileName);
                string FileExtension = Path.GetExtension(missingPerson.ImageFile.FileName);
                FileName = Guid.NewGuid().ToString() + FileExtension;
                string UploadPath = ConfigurationManager.AppSettings["UserImagePath"].ToString();
                missingPerson.ImagePath = UploadPath + FileName;
                missingPerson.ImageFile.SaveAs(Server.MapPath(missingPerson.ImagePath));

                User user = (User)Session["User"];
                missingPerson.AddedByUserId = user.Id;
                missingPerson.addMissingPerson();
                Debug.WriteLine("DZIALA");

                ViewBag.MissingPersonList = Models.MissingPerson.getList();

                return(View("MissingPersonList"));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(string id, [Bind("Ailments,Clothes,DateOfBirth,EyesColour,FurtherInformation,Gender,HairColor,Id,KnownPlaces,Medications,MissingSince,Name,OperationId,Size,SkinType,SpecialCharacteristics,Weight")] MissingPerson missingPerson)
        {
            if (id != missingPerson.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(missingPerson);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MissingPersonExists(missingPerson.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { id = missingPerson.OperationId }));
            }
            return(View(missingPerson));
        }
 public ActionResult deletePerson(int id)
 {
     if (checkLogged() && checkAdmin())
     {
         MissingPerson person = MissingPerson.findById(id);
         person.delete();
     }
     return(RedirectToAction("PeopleList"));
 }
        public List <MissingPerson> MissingPeopleSource()
        {
            List <MissingPerson> Mis = new List <MissingPerson>();

            MissingPerson person = new MissingPerson();

            person.Name = "PersonName";

            return(Mis);
        }
Ejemplo n.º 6
0
        public async Task <IHttpActionResult> GetMissingPerson(int id)
        {
            MissingPerson missingPerson = await db.MissingPersons.FindAsync(id);

            if (missingPerson == null)
            {
                return(NotFound());
            }

            return(Ok(missingPerson));
        }
Ejemplo n.º 7
0
        public async Task <IHttpActionResult> PostMissingPerson(MissingPerson missingPerson)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MissingPersons.Add(missingPerson);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = missingPerson.Id }, missingPerson));
        }
Ejemplo n.º 8
0
        public async Task <IHttpActionResult> DeleteMissingPerson(int id)
        {
            MissingPerson missingPerson = await db.MissingPersons.FindAsync(id);

            if (missingPerson == null)
            {
                return(NotFound());
            }

            db.MissingPersons.Remove(missingPerson);
            await db.SaveChangesAsync();

            return(Ok(missingPerson));
        }
 public ActionResult PersonDetails(int id)
 {
     checkLogged();
     if (id != 0)
     {
         MissingPerson person = MissingPerson.findById(id);
         ViewBag.person = person;
         return(View());
     }
     else
     {
         return(RedirectToAction("PeopleList"));
     }
 }
Ejemplo n.º 10
0
        private MissingPerson InitializeMissingPerson(string imgLocation)
        {
            MissingPerson missingPerson = new MissingPerson();

            missingPerson.firstName              = firstNameBox.Text;
            missingPerson.lastName               = lastNameBox.Text;
            missingPerson.lastSeenDate           = lastSeenOnPicker.Value.ToString();
            missingPerson.lastSeenLocation       = locationBox.Text;
            missingPerson.Additional_Information = additionalInfoBox.Text;
            missingPerson.dateOfBirth            = dateOfBirthPicker.Text;
            missingPerson.faceImg   = imgLocation;
            missingPerson.faceToken = faceToken;

            return(missingPerson);
        }
        public ActionResult PeopleList(string value)
        {
            checkLogged();
            List <MissingPerson> list = null;

            if (value == null)
            {
                list = MissingPerson.FindAll();
            }
            else
            {
                MPDContext db = new MPDContext();
                list = db.MissingPersons.Where(u => (u.Firstname.Contains(value)) || u.Lastname.Contains(value)).ToList();
            }
            ViewBag.MissingPeople = list;
            return(View());
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("Ailments,Clothes,DateOfBirth,EyesColour,FurtherInformation,Gender,HairColor,KnownPlaces,Medications,MissingSince,Name,OperationId,Size,SkinType,SpecialCharacteristics,Weight")] MissingPerson missingPerson)
        {
            if (ModelState.IsValid)
            {
                _context.Add(missingPerson);
                await _context.SaveChangesAsync();

                OperationActionsController operationActionsController = new OperationActionsController(_context);
                await operationActionsController.Create(missingPerson.OperationId,
                                                        "Vermisstendaten erfasst",
                                                        string.Empty,
                                                        $"{missingPerson.Name}, vermisst seit {missingPerson.MissingSince}"); // TODO: I18n

                return(RedirectToAction(nameof(Index), new { id = missingPerson.OperationId }));
            }
            return(View(missingPerson));
        }
        public ActionResult EditPerson(MissingPerson newData)
        {
            checkLogged();
            MPDContext    db     = new MPDContext();
            MissingPerson person = MissingPerson.findById(newData.PersonId);

            person.Firstname   = newData.Firstname;
            person.Lastname    = newData.Lastname;
            person.Age         = newData.Age;
            person.Location    = newData.Location;
            person.Description = newData.Description;

            db.MissingPersons.AddOrUpdate(person);
            db.SaveChanges();
            ViewBag.formPerson = person;

            return(RedirectToAction("PersonDetails", new { id = person.PersonId }));
        }
 public ActionResult AddNew(MissingPerson person)
 {
     if (checkLogged())
     {
         person.addImage(person.ImageFile);
         person.UserId = loggedUser.UserId;
         MPDContext db = new MPDContext();
         db.MissingPersons.Add(person);
         db.SaveChanges();
         ModelState.Clear();
         ViewBag.Message = "Dodano zaginionego!";
         return(View());
     }
     else
     {
         ViewBag.Message = "Nie możesz dodać użytkownika, musisz się zalogować!";
         return(View(person));
     }
 }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            //object navigationParameter;
            //if (e.PageState != null && e.PageState.ContainsKey("SelectedItem"))
            //{
            //    navigationParameter = e.PageState["SelectedItem"];
            //}
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            MissingPerson item = (MissingPerson)e.NavigationParameter;

            List <MissingPerson> Lis = new List <MissingPerson>();

            Lis.Add(item);

            itemsViewSource.Source = Lis;

            //this.DefaultViewModel["Group"] = item.Group;
            //this.DefaultViewModel["Items"] = item.Group.Items;
            //this.flipView.SelectedItem = item;
        }
Ejemplo n.º 16
0
        public async Task <ActionResult> AddMissingPerson(MissingPerson missingPersons)
        {
            HttpClientWrapper httpClient = new HttpClientWrapper();

            if (await new FaceApiCalls(httpClient).AddFaceToFaceset(missingPersons.faceToken) == null)
            {
                //TODO: have some proper things to do here.
                throw new SystemException("ding dong");
            }
            byte[] byteArray = Convert.FromBase64String(missingPersons.faceImg);
            using (var ms = new MemoryStream(byteArray, 0, byteArray.Length))
            {
                Bitmap image  = (Bitmap)Bitmap.FromStream(ms);
                string imgLoc = await httpClient.PostImageToApiString(image);

                missingPersons.faceImg = imgLoc;
                HttpContent content = await httpClient.PostMissingPersonToApiAsync(missingPersons);

                var name = User.Identity.Name;
                ApplicationDbContext db = new ApplicationDbContext();
                ApplicationUser      applicationUser = db.Users.FirstOrDefault(x => x.UserName == name);

                string contactPerson = await httpClient.Get("http://viltomas.eu/api/ContactPersons/" + applicationUser.idas);

                string missingParsed = await content.ReadAsStringAsync();

                ContactPerson  contactP = JsonConvert.DeserializeObject <ContactPerson>(contactPerson);
                MissingPerson  missingP = JsonConvert.DeserializeObject <MissingPerson>(missingParsed);
                MissingContact mc       = new MissingContact
                {
                    contactPerson = contactP,
                    missingPerson = missingP
                };
                var contentResponse = await httpClient.PostRelToApi(mc);

                var contentString = await content.ReadAsStringAsync();

                return(View("View"));
            }
        }
Ejemplo n.º 17
0
        public async Task <ActionResult> AddMissingPerson(MissingPerson missingPersons)
        {
            HttpClientWrapper httpClient = new HttpClientWrapper();

            if (await new FaceApiCalls(httpClient).AddFaceToFaceset(missingPersons.faceToken) == null)
            {
                //TODO: have some proper things to do here.
                throw new SystemException("ding dong");
            }
            byte[] byteArray = Convert.FromBase64String(missingPersons.faceImg);
            using (var ms = new MemoryStream(byteArray, 0, byteArray.Length))
            {
                Bitmap image  = (Bitmap)Bitmap.FromStream(ms);
                string imgLoc = await httpClient.PostImageToApiString(image);

                missingPersons.faceImg = imgLoc;
                HttpContent content = await httpClient.PostMissingPersonToApiAsync(missingPersons);

                string missingParsed = await content.ReadAsStringAsync();

                return(View("View"));
            }
        }
Ejemplo n.º 18
0
        public ActionResult GetPopUpData(int personId)
        {
            MissingPerson person = MissingPerson.getPopUpInfo(personId);

            return(Json(person));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Gets information about the missing person
        /// Author: Tomas Drasutis
        /// </summary>
        private async void addMissingPersonButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Verify that properties are valid
                if (!Regex.IsMatch(firstNameBox.Text, nameRegex) || firstNameBox.Text.Equals(""))
                {
                    MessageBox.Show(Messages.incorrectMissingFirstNamePattern);
                    return;
                }

                if (!Regex.IsMatch(lastNameBox.Text, nameRegex) || lastNameBox.Text.Equals(""))
                {
                    MessageBox.Show(Messages.incorrectLastNamePattern);
                    return;
                }

                if (!Regex.IsMatch(contactFirstNameBox.Text, nameRegex) || contactFirstNameBox.Text.Equals(""))
                {
                    MessageBox.Show(Messages.incorrectContactFirstNamePattern);
                    return;
                }

                if (!Regex.IsMatch(contactLastNameBox.Text, nameRegex) || contactLastNameBox.Text.Equals(""))
                {
                    MessageBox.Show(Messages.incorrectContactLastNamePattern);
                    return;
                }

                if (!Regex.IsMatch(contactPhoneNumberBox.Text, phoneRegex) || contactPhoneNumberBox.Text.Equals(""))
                {
                    MessageBox.Show(Messages.incorrectPhoneNumberPattern);
                    return;
                }

                if (!Regex.IsMatch(contactEmailAddressBox.Text, emailRegex) || contactEmailAddressBox.Text.Equals(""))
                {
                    MessageBox.Show(Messages.incorrectEmailPattern);
                    return;
                }

                //this might be needed for a picture upload in the future.
                Bitmap missingPersonImage = new Bitmap(missingPersonPictureBox.Image);

                if (validImage)
                {
                    if (await new FaceApiCalls(new HttpClientWrapper()).AddFaceToFaceset(faceToken) == null)
                    {
                        //TODO: have some proper things to do here.
                        throw new SystemException(Messages.invalidApiResponse);
                    }
                    HttpContent content = await httpClient.PostImageToApi(missingPersonImage);

                    string response = await content.ReadAsStringAsync();

                    //post image to api
                    Console.WriteLine("posting image to api" + response);

                    //initialize contact person
                    ContactPerson contact = InitializeContactPerson();

                    //initialize missing person
                    MissingPerson missing = InitializeMissingPerson(response);

                    content = await httpClient.PostContactPersonToApiAsync(contact);

                    string contact1 = await content.ReadAsStringAsync();

                    Console.WriteLine("contact" + contact1);
                    content = await httpClient.PostMissingPersonToApiAsync(missing);

                    string missing1 = await content.ReadAsStringAsync();

                    Console.WriteLine("missing" + missing1);
                    MissingPerson  parsedMiss = JsonConvert.DeserializeObject <MissingPerson>(missing1);
                    ContactPerson  parsedCont = JsonConvert.DeserializeObject <ContactPerson>(contact1);
                    MissingContact misscont   = new MissingContact();
                    misscont.contactPerson = parsedCont;
                    misscont.missingPerson = parsedMiss;
                    //create a relationship between persons
                    Console.WriteLine(await httpClient.PostRelToApi(misscont));
                }
                else
                {
                    MessageBox.Show(Messages.invalidImage);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                MessageBox.Show(Messages.errorWhileSavingPerson);
            }
        }