Exemplo n.º 1
0
        public JsonResult Post(DeadPerson deadp)
        {
            string query = @"
                insert into dbo.DeadPeople values
                (N'" + deadp.Name + @"', N'" + deadp.DateOfBirth + @"',
                 N'" + deadp.DateOfDeath + @"', '" + deadp.LodgingId + @"')";

            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("CmentarzConnectionTEST");
            SqlDataReader myReader;

            using (SqlConnection myCon = new SqlConnection(sqlDataSource))
            {
                myCon.Open();
                using (SqlCommand myCommand = new SqlCommand(query, myCon))
                {
                    myReader = myCommand.ExecuteReader();
                    table.Load(myReader);;

                    myReader.Close();
                    myCon.Close();
                }
                return(new JsonResult("Dodano pomyślnie"));
            }
        }
Exemplo n.º 2
0
        public JsonResult Put(DeadPerson deadp)
        {
            string query = @"
                update dbo.DeadPeople set
                Name = N'" + deadp.Name + @"',
                DateOfBirth = '" + deadp.DateOfBirth + @"',
                DateOfDeath = '" + deadp.DateOfDeath + @"',
                LodgingId = '" + deadp.LodgingId + @"'
                where IdDeadPerson = '" + deadp.IdDeadPerson + @"'";

            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("CmentarzConnectionTEST");
            SqlDataReader myReader;

            using (SqlConnection myCon = new SqlConnection(sqlDataSource))
            {
                myCon.Open();
                using (SqlCommand myCommand = new SqlCommand(query, myCon))
                {
                    myReader = myCommand.ExecuteReader();
                    table.Load(myReader);;

                    myReader.Close();
                    myCon.Close();
                }
                return(new JsonResult("Zaktualizowano pomyślnie"));
            }
        }
Exemplo n.º 3
0
 internal void delete(DeadPerson deadPerson)
 {
     using (ApplicationDbContext dbContext = new ApplicationDbContext())
     {
         new DeadPersonRepository(dbContext).delete(deadPerson);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 4
0
        public void DeleteDeadPersonFromDb(DeadPerson deadp)
        {
            if (deadp == null)
            {
                throw new ArgumentNullException(nameof(deadp));
            }

            _context.DeadPeople.Remove(deadp);
        }
Exemplo n.º 5
0
        public void AddDeadPersonToDb(DeadPerson deadp)
        {
            if (deadp == null)
            {
                throw new ArgumentException(nameof(deadp));
            }

            _context.DeadPeople.Add(deadp);
        }
Exemplo n.º 6
0
 public void update(DeadPerson deadPerson)
 {
     try
     {
         using (ApplicationDbContext dbContext = new ApplicationDbContext())
         {
             new DeadPersonRepository(dbContext).update(deadPerson);
             dbContext.SaveChanges();
         }
     }
     catch (Exception ex) { }
 }
Exemplo n.º 7
0
        public void Handle(PersonDied message)
        {
            Person person = storage.Load <Person>(message.Id);

            DeadPerson deadPerson = new DeadPerson(person.AggregateId)
            {
                Name = person.Name
            };

            storage.Remove(person);
            storage.Add(deadPerson);
        }
        public void Handle(PersonDied message)
        {
            Person     person     = storage.Items <Person>().Where(p => p.Id == message.Id).Single();
            DeadPerson deadPerson = new DeadPerson
            {
                Id   = person.Id,
                Name = person.Name
            };

            storage.Remove(person);
            storage.Add(deadPerson);
        }
Exemplo n.º 9
0
 public DeadPerson getByID(Guid id)
 {
     try
     {
         DeadPerson deadPerson = null;
         using (ApplicationDbContext db = new ApplicationDbContext())
         {
             deadPerson = new DeadPersonRepository(db).getByID(id.ToString());
         }
         return(deadPerson);
     }
     catch (Exception ex) { }
     return(null);
 }
Exemplo n.º 10
0
 public DeadPerson create(DeadPerson deadPerson)
 {
     try
     {
         using (ApplicationDbContext dbContext = new ApplicationDbContext())
         {
             new DeadPersonRepository(dbContext).create(deadPerson);
             dbContext.SaveChanges();
             return(deadPerson);
         }
     }
     catch (Exception ex) { }
     return(null);
 }
Exemplo n.º 11
0
        private void bindFuneralList()
        {
            try
            {
                List <Funeral>          listFuneral          = new FuneralService().getAll();
                List <Guid>             listFuneralID        = listFuneral.Select(x => x.FuneralID).ToList();
                List <DeadPerson>       listDeadPerson       = new DeadPersonService().getBy(x => listFuneralID.Contains(x.FuneralID));
                List <FuneralViewModel> listFuneralViewModel = new List <FuneralViewModel>();

                for (int i = 0; i < listFuneral.Count; i++)
                {
                    DeadPerson deadPerson = listDeadPerson.FirstOrDefault(x => x.FuneralID.Equals(listFuneral[i].FuneralID));
                    listFuneralViewModel.Add(new FuneralViewModel(listFuneral[i], deadPerson));
                }

                repFuneral.DataSource = listFuneralViewModel;
                repFuneral.DataBind();
            }
            catch (Exception ex) { }
        }
Exemplo n.º 12
0
 public void AddDeadPersonToDb(DeadPerson deadp)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
 public BurialPlaceViewModel(BurialPlace burialPlace, DeadPerson deadPerson)
 {
     this.BurialPlace = burialPlace;
     this.DeadPerson  = deadPerson;
 }
Exemplo n.º 14
0
 public FuneralViewModel(Funeral funeral, DeadPerson deadPerson)
 {
     this.Funeral    = funeral;
     this.DeadPerson = deadPerson;
 }
Exemplo n.º 15
0
 public void UpdateDeadPerson(DeadPerson deadp)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 16
0
 public void DeleteDeadPersonFromDb(DeadPerson deadp)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 public DeadPersonViewModel(DeadPerson deadPerson)
 {
     this.DeadPerson = deadPerson;
 }
Exemplo n.º 18
0
 public void UpdateDeadPerson(DeadPerson deadp)
 {
 }
Exemplo n.º 19
0
 public BookedServiceViewModel(BookedService bookedService, DeadPerson deadPerson)
 {
     this.BookedService = bookedService;
     this.DeadPerson    = deadPerson;
 }
        private void saveDeadPerson()
        {
            Funeral funeral = null;

            DeadPerson deadPerson = null;

            if (IsCreateMode)
            {
                funeral = new Funeral()
                {
                    FuneralID = Guid.NewGuid()
                };

                deadPerson = new DeadPerson()
                {
                    DeadPersonID = Guid.NewGuid()
                };
            }
            else
            {
                deadPerson = new DeadPersonService().getByID(this.DeadPersonID.ToString());
                funeral    = new FuneralService().getByID(deadPerson.FuneralID.ToString());
            }

            FuneralCompany      funeralCompany = new FuneralCompanyService().getByID(ddlFuneralCompany.SelectedValue);
            CemeteryStaffPerson cemeteryStaff  = new CemeteryStaffPersonService().getByID(ddlStaffPerson.SelectedValue);

            funeral.FuneralDate           = DateTime.ParseExact(txtFuneralDate.Text.Trim(), "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture);
            funeral.FuneralCompanyID      = funeralCompany.FuneralCompanyID;
            funeral.CemeteryStaffPersonID = cemeteryStaff.CemeteryStaffPersonID;

            BurialPlace burialPlace = new BurialPlaceService().getByID(ddlGraveNumber.SelectedValue);

            deadPerson.FirstName     = txtFirstName.Text;
            deadPerson.LastName      = txtLastName.Text;
            deadPerson.PESEL         = txtPesel.Text;
            deadPerson.Gender        = (EnumGender)int.Parse(ddlGender.SelectedValue);
            deadPerson.BurialPlaceID = burialPlace.BurialPlaceID;
            deadPerson.FuneralID     = funeral.FuneralID;

            try
            {
                Guid familyMemberID = Guid.Parse(ddlFamilyMember.SelectedValue);

                if (familyMemberID == Guid.Empty)
                {
                    deadPerson.FamilyMemberID = null;
                    deadPerson.FamilyMember   = null;
                }
                else
                {
                    if (!IsCreateMode)
                    {
                        deadPerson.FamilyMember = new FamilyMemberService().getBy(x => x.FamilyMemberID.Equals(familyMemberID))[0];
                    }

                    deadPerson.FamilyMemberID = familyMemberID;
                }
            }
            catch (Exception ex) { }

            if (IsCreateMode)
            {
                new FuneralService().create(funeral);

                new DeadPersonService().create(deadPerson);
                Response.Redirect(string.Format("/Pages/DeadPersonsDetails?DeadPersonID={0}", deadPerson.DeadPersonID.ToString()));
            }
            else
            {
                new DeadPersonService().update(deadPerson);
            }
        }