Exemplo n.º 1
0
        public ActionResult Aggiungi()
        {
            Persone p = new Persone(HostingEnvironment.MapPath(nomeFilee));

            p.Aggiungi();
            return(View("Index", p));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Persone persone = new Persone();
            Persone p2      = (Persone)persone;

            Console.WriteLine(p2.Name);
        }
Exemplo n.º 3
0
        // GET: Default
        public ActionResult Index()
        {
            string  nomeFile = HostingEnvironment.MapPath(@"~/App_Data/dati.xml");
            Persone p        = new Persone(nomeFile);

            return(View(p));
        }
        // GET: Default
        public ActionResult Index()
        {
            string fileName = HostingEnvironment.MapPath(@"~/App_Data/dati.xml");

            person = new Persone(fileName);
            return(View(person));
        }
Exemplo n.º 5
0
        public ActionResult Edit(int id, Persone furnitureRequestor)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Persone furniture = db.Persones.Find(id);
                    if (TryUpdateModel(furniture))
                    {
                        furniture.PhoneNumber = furnitureRequestor.PhoneNumber;
                        furniture.BirthDay    = furnitureRequestor.BirthDay;
                        furniture.BirthMonth  = furnitureRequestor.BirthMonth;
                        furniture.BirthYear   = furnitureRequestor.BirthYear;
                        furniture.Resident    = furnitureRequestor.Resident;
                        furniture.RegionId    = furnitureRequestor.RegionId;

                        db.SaveChanges();
                    }
                    return(RedirectToAction("Index"));
                }
                return(View(furnitureRequestor));
            }
            catch (Exception e)
            {
                return(View(furnitureRequestor));
            }
        }
        public ActionResult DelSelected()
        {
            var p = new Persone(nomeFile);

            p.Aggiungi();

            return(View("XMLReadWrite", p));
        }
        public ActionResult AddPredefinito()
        {
            var p = new Persone(nomeFile);

            p.Aggiungi();

            return(View("XMLReadWrite", p));
        }
        public ActionResult AddPerson()
        {
            string fileName = HostingEnvironment.MapPath(@"~/App_Data/dati.xml");

            person = new Persone(fileName);
            person.Aggiungi();
            return(View("Index", person));
        }
 public Biblioteca()
 {
     for (int i = 0; i < 5; i++)
     {
         Libri.Add(new Libro("Libro " + i));
         Persone.Add(new Persona("Persona " + i));
     }
 }
Exemplo n.º 10
0
 public void AddPersone(Persone persone)
 {
     if (persone != null)
     {
         context.Add(persone);
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
        public ActionResult New()
        {
            Persone contact = new Persone();

            ViewBag.RegionList = GetAllRegions();
            ViewBag.GenderList = GetAllGenderTypes();
            return(View(contact));
        }
Exemplo n.º 12
0
        public void Add(Persone persone)
        {
            HashAlgorithm hashAlgorithm = new SHA256CryptoServiceProvider();
            var           byteValue     = Encoding.UTF8.GetBytes(persone.PassWord);
            var           byteHash      = hashAlgorithm.ComputeHash(byteValue);
            string        pass          = Convert.ToBase64String(byteHash);

            persone.PassWord = pass;
            context.Persones.Add(persone);
        }
Exemplo n.º 13
0
        public void UpdatePersone(int id, Persone persone)
        {
            var personeExist = context.Persones.FirstOrDefault(x => x.Id == id);

            if (personeExist != null)
            {
                personeExist.Name  = persone.Name;
                personeExist.Phone = persone.Phone;
                context.SaveChanges();
            }
        }
Exemplo n.º 14
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            persone            = new Persone(30);
            dgDati.ItemsSource = persone;

            var anni = (from p in persone
                        select p.Data.Year).Distinct();

            cboxAnni.ItemsSource   = anni;
            cboxAnni.SelectedIndex = 0;
        }
Exemplo n.º 15
0
        public Persone Persones(int personeId)
        {
            Persone p1 = context.Persones.FirstOrDefault(x => x.Id == personeId);

            if (p1 != null)
            {
                context.Entry(p1).Collection(x => x.Contacts).Load();
                return(p1);
            }
            return(null);
        }
        public ActionResult XMLReadWrite(int nn = 0)
        {
            var p = new Persone(nomeFile);

            if (nn != 0)
            {
                p.Aggiungi();
            }

            return(View(p));
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            Persone[] persones = new Persone[] { new Persone("qwe", 4, 7, 9), new Persone("ghf", 44, 67, 89), new Persone("kl", 44, 47, 944) };
            Loader.Save("1.txt", persones);
            var persones2 = Loader.Load("1.txt");

            foreach (var item in persones2)
            {
                Console.WriteLine(item.ToString());
            }
            Console.ReadLine();
        }
Exemplo n.º 18
0
 public _Contacts()
 {
     Contacts              = new Contacts();
     CurPersoneCompare     = new Persone();
     TmpContacts           = new Contacts();
     TmpContactsCompare    = new Contacts();
     TMPPersoneCompare     = new Persone();
     OldTmpContactsCompare = new Contacts();
     OldPersoneCompare     = new Persone();
     Persone       = new Persone();
     showWindow    = new DefaultShowWindowService();
     dialogService = new DefaultDialogService();
 }
        public Biblioteca()
        {
            Libri.Add(new Libro("Guerra e pace"));
            Libri.Add(new Libro("Il signore degli anelli"));
            Libri.Add(new Libro("Iliade"));
            Libri.Add(new Libro("Apologia di Socrate"));
            Libri.Add(new Libro("Le affinità elettive"));

            Persone.Add(new Persona("Pippo"));
            Persone.Add(new Persona("Topolino"));
            Persone.Add(new Persona("Paperino"));
            Persone.Add(new Persona("Gastone"));
            Persone.Add(new Persona("Nonna Papera"));
        }
Exemplo n.º 20
0
        public ActionResult Edit(int?id)
        {
            if (id.HasValue)
            {
                Persone furniture = db.Persones.Find(id);

                if (furniture == null)
                {
                    return(HttpNotFound("Couldn't find the person with id " + id.ToString() + "!"));
                }
                return(View(furniture));
            }
            return(HttpNotFound("Couldn't find the persone with id " + id.ToString() + "!"));
        }
Exemplo n.º 21
0
        public ActionResult Delete(int id)
        {
            Rezervation rezervation = ctx.Rezervations.Find(id);
            Persone     contact     = ctx.Persones.Find(rezervation.Persone.PersoneId);

            if (rezervation != null)
            {
                ctx.Rezervations.Remove(rezervation);
                ctx.Persones.Remove(contact);
                ctx.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(HttpNotFound("Couldn't find the rezervation with id " + id.ToString() + "!"));
        }
        public IActionResult Post([FromBody] Persone persone)
        {
            if (persone == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(persone));
            }
            repository.AddPersone(persone);
            return(CreatedAtAction("GetById", new { id = persone.Id }, persone));
        }
Exemplo n.º 23
0
 public void Edite(Persone persone)
 {
     try
     {
         Persone originalPersone = _personeContext.persones.Find(persone.Id);
         originalPersone.Iin       = persone.Iin;
         originalPersone.FirstName = persone.FirstName;
         originalPersone.LastName  = persone.LastName;
         originalPersone.BirthDate = persone.BirthDate;
         _personeContext.SaveChanges();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
 }
Exemplo n.º 24
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                persone            = new Persone("Persone.csv");
                dgDati.ItemsSource = persone;

                // LINQ
                var anni = (from p in persone
                            orderby p.Data.Year descending
                            select p.Data.Year).Distinct();

                cboxAnni.ItemsSource   = anni;
                cboxAnni.SelectedIndex = 0;
            }
            catch { }
        }
Exemplo n.º 25
0
        public Persone GetPersoneById(int personeId, int contactId)
        {
            Persone p1 = context.Persones.FirstOrDefault(x => x.Id == personeId);

            if (p1 != null)
            {
                context.Entry(p1).Collection(x => x.Contacts).Query()
                .FirstOrDefault(x => x.PersoneId == p1.Id && x.Id == contactId);
                if (!p1.Contacts.Any())
                {
                    return(null);
                }
                return(p1);
            }

            return(null);
        }
        public IActionResult Put(int id, [FromBody] Persone persone)
        {
            if (persone == null)
            {
                return(BadRequest());
            }

            Persone personeExist = repository.PersoneById(id);

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

            repository.UpdatePersone(id, persone);

            return(CreatedAtAction("GetById", new { id = personeExist.Id }, personeExist));
        }
Exemplo n.º 27
0
        public void DeletePersone(Persone persone)
        {
            var personeDeleted = context.Persones.Find(persone.Id);

            if (personeDeleted == null)
            {
                return;
            }

            context.Entry(personeDeleted).Collection(x => x.Contacts).Load();

            foreach (var contact in personeDeleted.Contacts)
            {
                context.Contacts.Remove(contact);
            }
            context.Persones.Remove(personeDeleted);
            context.SaveChanges();
        }
Exemplo n.º 28
0
        //public ICommand Aggiungi { get; set; }
        void Add(object obj)
        {
            PersonaViewModel p;

            if (obj == null)
            {
                p = new PersonaViewModel()
                {
                    Nome = "Name", Cognome = "Surname", Telefono = "Phone Number"
                };
                Persone.Add(p);
                PersonaSelezionata = (PersonaViewModel)obj;
            }
            else
            {
                this.Persone.Add((PersonaViewModel)obj);
                PersonaSelezionata = (PersonaViewModel)obj;
            }
        }
Exemplo n.º 29
0
 public ActionResult New(Persone contactRequest)
 {
     ViewBag.RegionList = GetAllRegions();
     ViewBag.GenderList = GetAllGenderTypes();
     try
     {
         if (ModelState.IsValid)
         {
             db.Persones.Add(contactRequest);
             db.SaveChanges();
             return(RedirectToAction("Index", "Room"));
         }
         return(View(contactRequest));
     }
     catch (Exception e)
     {
         return(View(contactRequest));
     }
 }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            Persone Codici = new Persone();

            //Ricerca
            Console.WriteLine("Scrivere il valore che si vuole cercare");
            try
            {
                Codici.RicercaTotale(Console.ReadLine());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //Fine Ricerca

            Console.WriteLine("\n-------------");

            Codici.SalvataggioDatiinJson();

            Console.WriteLine(Codici);
        }