public bool Create(Parish entity)
 {
     _db.Parishes.Add(entity);
     //Save
     return(Save());
     //Save
 }
Exemplo n.º 2
0
 public ParishViewModel(Parish parish)
 {
     //Parish = parish;
     parish.Confessions = parish.Confessions.Select(c =>
     {
         var cE             = c;
         cE.DayOfWeek       = Enum.GetName(typeof(DayOfWeek), cE.Day);
         cE.EndTimeString   = c.EndTime.ToLongTimeString();
         cE.StartTimeString = c.StartTime.ToLongTimeString();
         return(cE);
     }).ToList();
     parish.Masses = parish.Masses.Select(m =>
     {
         var mE             = m;
         mE.DayOfWeek       = Enum.GetName(typeof(DayOfWeek), mE.Day);
         mE.EndTimeString   = m.EndTime.ToLongTimeString();
         mE.StartTimeString = m.StartTime.ToLongTimeString();
         return(mE);
     }).ToList();
     Parish         = parish;
     Confession     = Parish.Confessions.Count() > 0 ? "Confession Time" : "";
     Mass           = Parish.Masses.Count() > 0 ? "Mass Time" : "";
     Title          = Parish.Name;
     ViewMapCommand = new Command(async() => await ExecuteViewMapCommand());
 }
Exemplo n.º 3
0
        private void Parish_SelectedIndexChanged(object sender, EventArgs e)
        {
            var    picker = sender as Picker;
            Parish ds     = new Parish();

            ds = (Parish)picker.SelectedItem;
            if (ds != null)
            {
                bList = App.Database.GetBridgeItemsAsync().Result;
                this.Bridge.ItemsSource        = bList.Where(p => p.Parish_Id == ds.ID).ToList();
                this.Bridge.ItemDisplayBinding = new Binding("Bridge_Name");
                this.Bridge.IsEnabled          = true;

                var detail = (vmDetail)BindingContext;

                if (detail.bridge != null)
                {
                    this.Bridge.SelectedItem = (from p in bList
                                                where p.ID == detail.bridge.ID
                                                select p).FirstOrDefault();
                }
            }
            else
            {
                this.Bridge.ItemDisplayBinding = null;
                this.Bridge.IsEnabled          = false;
                this.Bridge.WidthRequest       = 75;
            }
        }
Exemplo n.º 4
0
 public async Task <ActionResult> EditParish(int id, FormCollection collection, Parish parish)
 {
     try
     {
         Parish thisParish = db.Parishes.Find(id);
         thisParish.Name            = parish.Name;
         thisParish.Street1         = parish.Street1;
         thisParish.Street2         = parish.Street2;
         thisParish.City            = parish.City;
         thisParish.State           = parish.State;
         thisParish.Zip             = parish.Zip;
         thisParish.WebsiteURL      = parish.WebsiteURL;
         thisParish.Phone           = parish.Phone;
         thisParish.RecieveComments = parish.RecieveComments;
         // if lat & long is 0, fill them in
         if (thisParish.Lat == 0)
         {
             thisParish = await SetLatLong(thisParish);
         }
         db.SaveChanges();
         return(RedirectToAction("Index", "Events"));
     }
     catch
     {
         return(View(parish));
     }
 }
Exemplo n.º 5
0
 public Address()
 {
     Parish    = new Parish();
     Community = new Community();
     Sector    = new Sector();
     Street    = new Street();
 }
Exemplo n.º 6
0
        private void UpdateRecord()
        {
            using (new WaitCursor())
            {
                Parish oclsParish = new Parish();
                Parish clsParish  = new Parish();

                oclsParish.Parish_ID = System.Convert.ToInt16((Grid.SelectedCells[0].Column.GetCellContent(Grid.SelectedItem) as TextBlock).Text);
                oclsParish           = ParishData.Select_Record(oclsParish);

                if (VerifyData() == true)
                {
                    SetData(clsParish);
                    Boolean bSucess = new Boolean();
                    bSucess = ParishData.Update(oclsParish, clsParish);
                    if (bSucess == true)
                    {
                        GoBack_To_Grid();
                    }
                    else
                    {
                        MessageBox.Show("Update failed.", "Error");
                    }
                }
            }
        }
Exemplo n.º 7
0
 private void button2_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(textBox2.Text))
         {
             using (ExpressTaxi ctx = new ExpressTaxi(conn))
             {
                 Parish v = ctx.Parishes.SingleOrDefault(r => r.PAR_NAME.ToUpper() == textBox2.Text.ToUpper());
                 if (v == null)
                 {
                     v          = new Parish();
                     v.PAR_NAME = textBox2.Text;
                     ctx.Parishes.InsertOnSubmit(v);
                     ctx.SubmitChanges();
                     Config.ShowInfoMessage("Completed adding the Parish to the database.");
                     textBox2.Text = null;
                 }
                 else
                 {
                     Config.ShowErrorMessage("The Parish already exists in the database, cannot duplicate the entry");
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         log.Error(ex);
         Config.ShowErrorMessage("Failed to add the New Parish, an internal error has occurred.");
     }
 }
Exemplo n.º 8
0
 protected override Church Parse()
 {
     return(new Church
     {
         Id = ToInt(SimbahanID),
         StreetNumber = ToInt(StreetNo),
         StreetName = StreetName.ToString(),
         Barangay = Barangay.ToString(),
         StateProvince = StateOrProvince.ToString(),
         City = City.ToString(),
         ZipCode = ZipCode.ToString(),
         CompleteAddress = CompleteAddress.ToString(),
         Diocese = Diocese.ToString(),
         Parish = Parish.ToString(),
         Priest = ParishPriest.ToString(),
         Vicariate = Vicariate.ToString(),
         DateEstablished = DateEstablished.ToString(),
         LastUpdate = ToDateTime(LastUpdate),
         FeastDay = FeastDay.ToString(),
         ContactNo = ContactNo.ToString(),
         Latitude = ToDouble(Latitude),
         Longitude = ToDouble(Longitude),
         HasAdorationChapel = ToBoolean(HasAdorationChapel),
         ChurchHistory = ChurchHistory.ToString(),
         OfficeHours = OfficeHours.ToString(),
         ChurchTypeId = ToInt(ChurchTypeID),
         Website = Website.ToString(),
         EmailAddress = EmailAddress.ToString(),
         DevotionSchedule = DevotionSchedule.ToString(),
         LocationId = ToInt(LocationID),
         ChurchCode = ChurchCode.ToString()
     });
 }
Exemplo n.º 9
0
        public ActionResult DeleteParish(int id)
        {
            Parish parish = db.Parishes.Find(id);

            db.Parishes.Remove(parish);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
 private void SetData(Parish clsParish)
 {
     using (new WaitCursor())
     {
         clsParish.ParishName  = System.Convert.ToString(tbParishName.Text);
         clsParish.KCSJDiocese = System.Convert.ToBoolean(System.Convert.ToBoolean(cbKCSJDiocese.IsChecked) ? true : false);
     }
 }
Exemplo n.º 11
0
        public ActionResult Details(int id = 0)
        {
            Parish parish = db.Parishes.Find(id);

            if (parish == null)
            {
                return(HttpNotFound());
            }
            return(View(parish));
        }
 public ActionResult Edit(Parish parish)
 {
     if (ModelState.IsValid)
     {
         db.Entry(parish).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(parish));
 }
Exemplo n.º 13
0
        private void ButtonAddParish_Click(object sender, RoutedEventArgs e)
        {
            AreButtonsEnabled = false;
            string name = TextBoxParishName.Text;

            if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
            {
                MessageBox.Show("Debe ingresar un nombre", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                AreButtonsEnabled = true;
                return;
            }

            Parish parish = new Parish()
            {
                Name = name
            };

            App.DbContext.Parishes.Add(parish);
            Community community = new Community()
            {
                Name   = name,
                Parish = parish
            };

            App.DbContext.Communities.Add(community);
            Sector sector = new Sector()
            {
                Name      = ' ',
                Community = community
            };

            App.DbContext.Sectors.Add(sector);

            Street street = new Street()
            {
                Name   = ' ',
                Sector = sector
            };

            try
            {
                App.DbContext.SaveChanges();
            }
            catch
            {
                MessageBox.Show("No se pudieron guardar los cambios en la base de datos", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                AreButtonsEnabled = true;
                return;
            }

            MessageBox.Show("Parroquía agregada con éxito", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information);
            TextBoxParishName.Text = string.Empty;
            Parishes.Add(parish);
            AreButtonsEnabled = true;
        }
Exemplo n.º 14
0
 public Task <int> SavePItemAsync(Parish parish, bool init = false)
 {
     if (parish.ID != 0 && !init)
     {
         return(Database.UpdateAsync(parish));
     }
     else
     {
         return(Database.InsertAsync(parish));
     }
 }
 /// <summary>
 /// Check that data is valid.
 /// </summary>
 /// <param name="context">Web service request context.</param>
 public void CheckData(WebServiceContext context)
 {
     County = County.CheckSqlInjection();
     County.CheckLength(GetCountyMaxLength(context));
     Municipality = Municipality.CheckSqlInjection();
     Municipality.CheckLength(GetMunicipalityMaxLength(context));
     Name = Name.CheckSqlInjection();
     Name.CheckLength(GetNameMaxLength(context));
     Parish = Parish.CheckSqlInjection();
     Parish.CheckLength(GetParishMaxLength(context));
 }
        public ActionResult Create(Parish parish)
        {
            if (ModelState.IsValid)
            {
                db.Parish.Add(parish);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(parish));
        }
Exemplo n.º 17
0
        // GET: Events/Create
        public ActionResult Create()
        {
            // [email protected]
            string thisUserID = User.Identity.GetUserId();
            People thisPerson = db.Peoples.Where(w => w.ApplicationUserId == thisUserID).First();
            Parish thisParish = db.Parishes.Where(w => w.AdminPersonId == thisPerson.ID).First();

            ViewBag.ParishId = thisParish.ID;

            ViewBag.SponserPersonId = new SelectList(db.Peoples, "ID", "FirstName");
            return(View());
        }
Exemplo n.º 18
0
        async void OnItemSelected(object sender, SelectionChangedEventArgs e)
        {
            if (e.CurrentSelection?.FirstOrDefault() == null)
            {
                return;
            }

            Parish item = e.CurrentSelection.FirstOrDefault() as Parish;
            await Navigation.PushAsync(new ParishViewPage(item));

            // Manually deselect item.
            ((CollectionView)sender).SelectedItem = null;
        }
Exemplo n.º 19
0
        public ActionResult SignupForEmails(Parish parish)
        {
            var userLoggedIn                     = User.Identity.GetUserId();
            var visitor                          = db.Peoples.Where(p => p.ApplicationUserId == userLoggedIn).FirstOrDefault();
            var parishToGetEmailsFrom            = db.Parishes.Where(p => p.ID == parish.ID).FirstOrDefault();
            PeopleParishViewModel personToParish = new PeopleParishViewModel();

            personToParish.PeopleId = visitor.ID;
            personToParish.ParishId = parishToGetEmailsFrom.ID;
            db.PeopleParishView.Add(personToParish);
            db.SaveChanges();

            return(RedirectToAction("MyParish", "Visitor"));
        }
Exemplo n.º 20
0
        // GET: ParishParish/Delete
        public ActionResult DeleteParish(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Parish parish = db.Parishes.Find(id);

            if (parish == null)
            {
                return(HttpNotFound());
            }
            return(View(parish));
        }
Exemplo n.º 21
0
        // GET: ParishProfile/Edit
        public ActionResult EditParish(int id)
        {
            //if (id == null)
            //{
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //}
            Parish parish = db.Parishes.Find(id);

            if (parish == null)
            {
                return(HttpNotFound());
            }
            return(View(parish));
        }
Exemplo n.º 22
0
        public async Task <ActionResult> CreateParish(Parish parish)
        {
            // set lat & long from geoDecoderRing
            parish = await SetLatLong(parish);

            // the user that is logged in is the AdminPersonID
            var appUserID = User.Identity.GetUserId();
            var personID  = db.Peoples.Where(w => w.ApplicationUserId == appUserID).FirstOrDefault().ID;

            parish.AdminPersonId = personID;
            db.Parishes.Add(parish);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 23
0
        public async ValueTask <IActionResult> Post([FromBody] ParishViewModel model)
        {
            if (ModelState.IsValid)
            {
                Parish parish = model.Convert <ParishViewModel, Parish>(_mapper);
                (bool succeeded, Parish addedParish, string error) = await _repo.Add(parish);

                if (succeeded)
                {
                    return(await Get(addedParish.Id));
                }
                return(BadRequest(new { Message = error }));
            }
            return(BadRequest(new { Errors = ModelState.Values.SelectMany(e => e.Errors).ToList() }));
        }
Exemplo n.º 24
0
    public static bool Update(Parish oldParish,
                              Parish newParish)
    {
        SqlConnection connection = MarriageData.GetConnection();
        string        updateStatement
            = "UPDATE "
              + "     [Parish] "
              + "SET "
              + "     [ParishName] = @NewParishName "
              + "    ,[KCSJDiocese] = @NewKCSJDiocese "
              + "WHERE "
              + "     [Parish_ID] = @OldParish_ID "
              + " AND [ParishName] = @OldParishName "
              + " AND [KCSJDiocese] = @OldKCSJDiocese "
              + "";
        SqlCommand updateCommand = new SqlCommand(updateStatement, connection);

        updateCommand.CommandType = CommandType.Text;
        updateCommand.Parameters.AddWithValue("@NewParishName", newParish.ParishName);
        updateCommand.Parameters.AddWithValue("@NewKCSJDiocese", newParish.KCSJDiocese);
        updateCommand.Parameters.AddWithValue("@OldParish_ID", oldParish.Parish_ID);
        updateCommand.Parameters.AddWithValue("@OldParishName", oldParish.ParishName);
        updateCommand.Parameters.AddWithValue("@OldKCSJDiocese", oldParish.KCSJDiocese);
        try
        {
            connection.Open();
            int count = updateCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        finally
        {
            connection.Close();
        }
    }
Exemplo n.º 25
0
    public static Parish Select_Record(Parish clsParishPara)
    {
        Parish        clsParish  = new Parish();
        SqlConnection connection = MarriageData.GetConnection();
        string        selectStatement
            = "SELECT "
              + "     [Parish_ID] "
              + "    ,[ParishName] "
              + "    ,[KCSJDiocese] "
              + "FROM "
              + "     [Parish] "
              + "WHERE "
              + "     [Parish_ID] = @Parish_ID "
              + "";
        SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

        selectCommand.CommandType = CommandType.Text;
        selectCommand.Parameters.AddWithValue("@Parish_ID", clsParishPara.Parish_ID);
        try
        {
            connection.Open();
            SqlDataReader reader
                = selectCommand.ExecuteReader(CommandBehavior.SingleRow);
            if (reader.Read())
            {
                clsParish.Parish_ID   = System.Convert.ToInt16(reader["Parish_ID"]);
                clsParish.ParishName  = System.Convert.ToString(reader["ParishName"]);
                clsParish.KCSJDiocese = System.Convert.ToBoolean(reader["KCSJDiocese"]);
            }
            else
            {
                clsParish = null;
            }
            reader.Close();
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        finally
        {
            connection.Close();
        }
        return(clsParish);
    }
Exemplo n.º 26
0
        public async Task <Parish> SetLatLong(Parish parish)
        {
            // This is the geoDecoderRing

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(parish.Street1.Replace(" ", "+"));
            stringBuilder.Append(";");
            stringBuilder.Append(parish.City.Replace(" ", "+"));
            stringBuilder.Append(";");
            stringBuilder.Append(parish.State.Replace(" ", "+"));
            // example: string url = @"https://maps.googleapis.com/maps/api/geocode/json?address={stringBuilder.ToString()}1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY";
            string url = @"https://maps.googleapis.com/maps/api/geocode/json?address=" +
                         stringBuilder.ToString() + "&key=" + Models.Access.apiKey;

            // httpclient

            WebRequest  request  = WebRequest.Create(url);
            WebResponse response = await request.GetResponseAsync();

            System.IO.Stream data = response.GetResponseStream();
            // tried this System.IO.Stream data = await GetGoogleGeocodeResponse(url);
            StreamReader reader = new StreamReader(data);
            // json-formatted string from maps api
            string responseFromServer = reader.ReadToEnd();

            response.Close();

            var root     = JsonConvert.DeserializeObject <ParishMapAPIData>(responseFromServer);
            var location = root.results[0].geometry.location;

            //var latitude = location.lat;
            //var longitude = location.lng;
            ////foreach (var singleResult in root.results)
            ////{
            ////    var location = singleResult.geometry.location;
            ////    var latitude = location.lat;
            ////    var longitude = location.lng;
            ////    // Do whatever you want with them.
            ////}
            parish.Lat  = location.lat;
            parish.Long = location.lng;
            return(parish);
        }
Exemplo n.º 27
0
    public static bool Add(Parish clsParish)
    {
        SqlConnection connection = MarriageData.GetConnection();
        string        insertStatement
            = "INSERT "
              + "     [Parish] "
              + "     ( "
              + "     [ParishName] "
              + "    ,[KCSJDiocese] "
              + "     ) "
              + "VALUES "
              + "     ( "
              + "     @ParishName "
              + "    ,@KCSJDiocese "
              + "     ) "
              + "";
        SqlCommand insertCommand = new SqlCommand(insertStatement, connection);

        insertCommand.CommandType = CommandType.Text;
        insertCommand.Parameters.AddWithValue("@ParishName", clsParish.ParishName);
        insertCommand.Parameters.AddWithValue("@KCSJDiocese", clsParish.KCSJDiocese);
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        finally
        {
            connection.Close();
        }
    }
Exemplo n.º 28
0
        async void OnListItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem != null)
            {
                var opening = (NavigationOpening)e.SelectedItem;

                vmDetail detail = new vmDetail();

                detail.ID = opening.ID;
                var dsList = App.Database.GetDistrictcItemsAsync().Result;
                var pList  = App.Database.GetParishItemsAsync().Result;
                var bList  = App.Database.GetBridgeItemsAsync().Result;

                var bridge = new Bridge();
                bridge = (from p in bList
                          where p.ID == opening.Bridge_ID
                          select p).FirstOrDefault();
                detail.bridge = bridge;

                var parish = new Parish();
                parish = (from p in pList
                          where p.ID == bridge.Parish_Id
                          select p).FirstOrDefault();
                detail.parish = parish;

                detail.district = (from p in dsList
                                   where p.ID == parish.District_ID
                                   select p).FirstOrDefault();
                detail.Entry_Date   = opening.Entry_Date;
                detail.Opening_Time = opening.Opening_Time;
                detail.Closing_Time = opening.Closing_Time;

                await Navigation.PushAsync(new NavigationDetailPage
                {
                    BindingContext = detail,
                    Title          = "Navigation Openings"
                });

                ;
            }
        }
Exemplo n.º 29
0
 private void InsertRecord()
 {
     using (new WaitCursor())
     {
         Parish clsParish = new Parish();
         if (VerifyData() == true)
         {
             SetData(clsParish);
             Boolean bSucess = new Boolean();
             bSucess = ParishData.Add(clsParish);
             if (bSucess == true)
             {
                 GoBack_To_Grid();
             }
             else
             {
                 MessageBox.Show("Insert failed.", "Error");
             }
         }
     }
 }
Exemplo n.º 30
0
    public static bool Delete(Parish clsParish)
    {
        SqlConnection connection = MarriageData.GetConnection();
        string        deleteStatement
            = "DELETE FROM "
              + "     [Parish] "
              + "WHERE "
              + "     [Parish_ID] = @OldParish_ID "
              + " AND [ParishName] = @OldParishName "
              + " AND [KCSJDiocese] = @OldKCSJDiocese "
              + "";
        SqlCommand deleteCommand = new SqlCommand(deleteStatement, connection);

        deleteCommand.CommandType = CommandType.Text;
        deleteCommand.Parameters.AddWithValue("@OldParish_ID", clsParish.Parish_ID);
        deleteCommand.Parameters.AddWithValue("@OldParishName", clsParish.ParishName);
        deleteCommand.Parameters.AddWithValue("@OldKCSJDiocese", clsParish.KCSJDiocese);
        try
        {
            connection.Open();
            int count = deleteCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        finally
        {
            connection.Close();
        }
    }