public Ministry InsertMinistry(Ministry ministry) { try { ministry.CreatedDateTime = DateTime.Now; db.Ministry.Add(ministry); db.SaveChanges(); if (ministry.UpInOutIds.Length > 0) { InsertUpInOutRelationships(ministry.Id, ministry.UpInOutIds); } if (ministry.ResourceInvolvementIds.Length > 0) { InsertResourceInvolvementIds(ministry.Id, ministry.ResourceInvolvementIds); } _loggerService.CreateLog("Jordan", "Ministry", "Create", ministry.ToString()); return(ministry); } catch (Exception e) { _loggerService.CreateLog("Jordan", "Ministry", "Create", ministry.ToString(), "Error creating this record: " + e.Message); return(null); } }
public string ComputeLocationString() { return(string.Join("-", Ministry.SlugifyString(), ContactType.SlugifyString(), ContactReason.SlugifyString())); }
public IActionResult Put(int id, [FromBody] Ministry ministry) { _context.Ministries.Update(ministry); _context.SaveChanges(); return(NoContent()); }
public ActionResult Create(MinistryViewModel viewModel) { if (ModelState.IsValid) { // Create a new ministry object Ministry myMinistry = new Ministry(viewModel); // Create or update a new address record Address myAddress = _db.Addresses.Add(viewModel.Address); // Update the AddressFK in the ministry object myMinistry.AddressId = myAddress.id; // Add the ministry to the dataset this._db.Ministries.Add(myMinistry); // Update the database this._db.SaveChanges(); // We are done, lets get outahere Response.Redirect("~/Ministry"); } else { var errors = ModelState.Where(v => v.Value.Errors.Any()); } return(View(viewModel)); }
private MinistryViewModel MapViewModel(Ministry ministry) { return(new MinistryViewModel { Id = ministry.Id, Event = ministry.Event, Purpose = ministry.Purpose, DesiredOutcome = ministry.DesiredOutcome, MinistryOwnerId = ministry.MinistryOwnerId, MinistryOwnerName = ministry.MinistryOwner.Name, PracticeId = ministry.PracticeId, PracticeName = ministry.Practice.Name, FunnelId = ministry.FunnelId, FunnelName = ministry.Funnel.Name, LocationId = ministry.LocationId, LocationName = ministry.Location.Name, CampusId = ministry.CampusId, CampusName = ministry.Campus.Name, UpInOutRelationships = ReturnUpInOutRelationshipViewModel(ministry.UpInOutRelationships), ResourceInvolvementRelationships = ReturnResourceInvolvementRelationshipViewModel(ministry.ResourceInvolvementRelationship), StartDate = (System.DateTime)(ministry.StartDate.HasValue ? ministry.StartDate : System.DateTime.MinValue), EndDate = (System.DateTime)(ministry.EndDate.HasValue ? ministry.EndDate : System.DateTime.MinValue), FrequencyId = ministry.FrequencyId, FrequencyName = ministry.Frequency.Name, KidCare = ministry.KidCare, LevelOfImportanceId = ministry.LevelOfImportanceId, LevelOfImportanceName = ministry.LevelOfImportance.Name, ApprovalId = ministry.ApprovalId, ApprovalName = ministry.Approval.Name, Comments = ministry.Comments, CreatedDateTime = (System.DateTime)(ministry.CreatedDateTime.HasValue ? ministry.CreatedDateTime : System.DateTime.MinValue), ModifiedDateTime = (System.DateTime)(ministry.ModifiedDateTime.HasValue ? ministry.ModifiedDateTime : System.DateTime.MinValue), Archived = ministry.Archived }); }
private async Task <MinisterViewModel> GetBiography(string key) { Debug.Assert(key != null); Ministry index = await Repository.GetMinistryAsync(key); if (index == null) { return(default(MinisterViewModel)); } MinisterViewModel model = new MinisterViewModel(); model.Minister = await Repository.GetMinisterAsync(index.Key); if (model.Minister == null || model.Minister.Headline == "") { return(null); } await LoadAsync(model); model.Ministry = index; model.Title = model.Minister.Headline; model.Footer = await GetFooter(index); return(model); }
public IActionResult DeleteMinistrySubmit(Ministry ministry) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } ministry = bookManager.getMinistry(ministry.id); ImageManager imageManager = new ImageManager(environment, "images/covers/ministry"); bool result = imageManager.deleteImage(ministry.frontcover); if (result) { bool result2 = imageManager.deleteImage(ministry.backcover); if (result2) { bookManager.Remove(ministry); bookManager.SaveChanges(); } else { Console.WriteLine("\n\n\n***There has been an error deleting the back cover file!***\n\n\n"); } } else { Console.WriteLine("\n\n\n***There has been an error deleting the front cover file!***\n\n\n"); } return(RedirectToAction("Ministry")); }
public Ministry DeleteMinistry(int id) { Ministry ministry = db.Ministry.Find(id); if (ministry == null) { _loggerService.CreateLog("Jordan", "Ministry", "Delete", string.Empty, $"Ministry {id} not found to delete."); return(null); } try { //TODO: have to remove the foreign key restraints before deleting the record db.Ministry.Remove(ministry); db.SaveChanges(); _loggerService.CreateLog("Jordan", "Ministry", "Delete", ministry.ToString()); } catch (Exception e) { _loggerService.CreateLog("Jordan", "Ministry", "Delete", ministry.ToString(), "Error deleting ministry: " + e.Message); return(null); } return(ministry); }
public IActionResult Post([FromBody] Ministry ministry) { var newMinistry = _context.Ministries.Add(ministry); _context.SaveChanges(); return(CreatedAtRoute("MinistryDetails", new { Id = newMinistry.Entity.Id }, newMinistry.Entity)); }
public Ministry GetMinistryById(int id) { Ministry ministry = db.Ministry.Find(id); _loggerService.CreateLog("Jordan", "Ministry", "Get By Id", id.ToString(), $"Results found: {ministry != null}"); return(ministry); }
public ActionResult DeleteConfirmed(Guid id) { Ministry ministry = db.Ministries.Find(id); db.Ministries.Remove(ministry); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult AddMinistrySubmit(Ministry ministry, IFormFile frontcover, IFormFile backcover) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } if (!ModelState.IsValid) { return(RedirectToAction("AddMinistry")); } ImageManager imageManager = new ImageManager(environment, "images/covers/ministry"); int result = imageManager.uploadImage(frontcover); switch (result) { case 1: Console.WriteLine("\n\n\n*** Wrong File Type! ***"); ViewData["feedback"] = "Wrong File Type"; return(RedirectToAction("AddMinistry")); case 2: Console.WriteLine("\n\n\n*** File Too Large! ***"); ViewData["feedback"] = "File Too Large"; return(RedirectToAction("AddMinistry")); case 3: Console.WriteLine("\n\n\n*** File Name Too Long! ***"); ViewData["feedback"] = "File Name Too Long"; return(RedirectToAction("AddMinistry")); case 4: Console.WriteLine("\n\n\n*** Error Saving File! ***"); ViewData["feedback"] = "Error Saving File"; return(RedirectToAction("AddMinistry")); case 5: ViewData["feedback"] = "Success"; ministry.frontcover = imageManager.fileName; int result2 = imageManager.uploadImage(backcover); if (result2 == 5) { ministry.backcover = imageManager.fileName; bookManager.Add(ministry); bookManager.SaveChanges(); return(RedirectToAction("Ministry")); } else { Console.WriteLine("\n\n\n***There has been an error adding the back cover!***"); return(RedirectToAction("AddMinistry")); } default: Console.WriteLine("\n\n\n*** No File Selected! ***"); ViewData["feedback"] = "No File Selected"; return(RedirectToAction("AddMinistry")); } }
public ActionResult Create() { var m = new Ministry { MinistryName = "NEW" }; DbUtil.Db.Ministries.InsertOnSubmit(m); DbUtil.Db.SubmitChanges(); return(Redirect($"/Ministry/#{m.MinistryId}")); }
public ActionResult Create() { var m = new Ministry { MinistryName = "NEW" }; CurrentDatabase.Ministries.InsertOnSubmit(m); CurrentDatabase.SubmitChanges(); return(Redirect($"/Ministry/#{m.MinistryId}")); }
//---------------------------------------------------------- ministry public IActionResult AddMinistry() { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } ViewBag.Current = ""; Ministry ministry = new Ministry(); return(View(ministry)); }
public void SetLocationOnContact() { var list = new List <string> { Ministry.ToString(), ContactType.ToString(), ContactReason.ToString() }; Location = ComputeLocationString(list); }
public static MinistryModel GetMinistryModel(this Ministry ministry) { var model = new MinistryModel { Id = ministry.Id, IdKey = ministry.IdKey, Name = ministry.Name, Description = ministry.Description }; return(model); }
public IActionResult EditMinistry(int id) { if (HttpContext.Session.GetString("auth") != "true") { return(RedirectToAction("Index", "Login")); } ViewBag.Current = ""; Ministry ministry = new Ministry(); ministry = bookManager.getMinistry(id); return(View(ministry)); }
public async Task <PostViewModel> LoadDetails(Post post) { Ministry ministry = post != null ? await Repository.GetMinistryAsync(post.LeadMinistryKey) : null; if (ministry == null) { return(null); } PostViewModel model = new PostViewModel(post); await LoadAsync(model); model.LeadMinistry = model.Ministries.FirstOrDefault(m => m.Index.Key == post.LeadMinistryKey); if (model.LeadMinistry == null) { // for Archived ministries model.LeadMinistry = new IndexModel(ministry); } model.Minister = await Repository.GetMinisterAsync(post.LeadMinistryKey); model.RelatedMinistryKeys = (await Repository.GetPostMinistriesAsync(post)).Select(m => m.Key); model.RelatedSectorKeys = (await Repository.GetPostSectorsAsync(post)).Select(m => m.Key); //Load [RelatedArticlesLength] posts, excluding the current post List <Post> posts = new List <Post>(); if (model.LeadMinistry.TopPost != null) { posts.Add(model.LeadMinistry.TopPost); } if (model.LeadMinistry.FeaturePost != null) { posts.Add(model.LeadMinistry.FeaturePost); } posts.AddRange(await Repository.GetLatestPostsAsync(ministry, RelatedArticlesLength - posts.Count + 1, null, MinistryFilter(ministry.Key))); model.RelatedArticles = posts.Where(e => e.Key != model.Post.Key).Take(RelatedArticlesLength); if (post.AssetUrl != null) { if (post.AssetUrl.Contains("facebook")) { model.FacebookAsset = await Repository.GetFacebookPostAsync(post.AssetUrl); } } model.Footer = await GetFooter(ministry); model.FacebookPostDetailsDictionary = await GetFacebookAssetDetails(post.Documents); return(model); }
public IHttpActionResult Post([FromBody] CreateMinistryModel model) { var ministry = new Ministry { Name = model.Name, Display = true }; db.Ministry.Add(ministry); db.SaveChanges(); return(Ok(ministry.Id)); }
public IHttpActionResult GetById(int id) { _loggerService.CreateLog(_user, "API", "MinistryController", "Ministry", "Get By Id", id.ToString(), null); Ministry ministry = _ministryRepository.GetMinistryById(id); if (ministry == null) { return(NotFound()); } return(Ok(MapViewModel(ministry))); }
// GET: Ministries/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ministry ministry = db.Ministries.Find(id); if (ministry == null) { return(HttpNotFound()); } return(View(ministry)); }
public ActionResult Edit([Bind(Include = "ID,MinistryCategoryId,MinistrySizeId,DenominationId,CountryId,Name,PhoneNumber1,PhoneNumber2,Email,Town,State,Vision,Mission,About,Logo,LogoBlob,FacebookUrl,TwitterUrl,YoutubeUrl,InstagramUrl,Source,DateEntered,DateClaimed,IsVerified,IsClaimed")] Ministry ministry) { if (ModelState.IsValid) { db.Entry(ministry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MinistrySizeId = new SelectList(db.MinistrySizes, "ID", "ID", ministry.MinistrySizeId); ViewBag.CountryId = new SelectList(db.Countries, "ID", "Name", ministry.CountryId); ViewBag.DenominationId = new SelectList(db.Denominations, "ID", "Type", ministry.DenominationId); ViewBag.MinistryCategoryId = new SelectList(db.MinistryCategories, "ID", "Name", ministry.MinistryCategoryId); return(View(ministry)); }
public static Uri GetMinisterUri(this Ministry ministry) { var uri = Properties.Settings.Default.NewsHostUri; if (ministry.Key != "office-of-the-premier") { uri = AppendUriSegment(uri, "ministries"); } uri = AppendUriSegment(uri, ministry.Key); uri = AppendUriSegment(uri, "biography"); return(uri); }
public Ministry Post(string name) { var date = DateTime.Now; var Ministrydata = new Ministry { Name = name, CreatedAt = date }; _context.Ministries.Add(Ministrydata); _context.SaveChanges(); return(Ministrydata); }
public MinistryViewModel ToMinistryViewModel(Ministry ministry) { return(new MinistryViewModel { // ChurchEvents = ministry.ChurchEvents, FollowUpHistories = ministry.FollowUpHistories, Id = ministry.Id, ImageUrl = ministry.ImageUrl, Name = ministry.Name, Admin = ministry.Admin, MinistryType = ministry.MinistryType, AdminId = ministry.Admin.Id, MinistryTypeId = ministry.MinistryType.Id, MinistryTypes = _combosHelper.GetComboMinistryTypes() }); }
protected void btnMinistryAdd_Click(object sender, ImageClickEventArgs e) { try { // Create a new Ministry Object _currentMinistry = new Ministry(); // Set whether Add / Edit if (txtMinistryID.Text.ToString() != "0") _currentMinistry.AddEditOption = 1; else _currentMinistry.AddEditOption = 0; // Assign values to the Ministry Object _currentMinistry.MinistryID = Convert.ToInt32(txtMinistryID.Text.ToString()); _currentMinistry.MinistryDescription = txtMinistry.Text.ToString(); // Add / Edit the Ministry TransactionResult result; _currentMinistry.ScreenMode = ScreenMode.Add; result = _currentMinistry.Commit(); // Display the Status - Whether successfully saved or not System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); // If successful, get the Ministry details if (result.Status == TransactionStatus.Success) { GetMinistryDetails(); txtMinistry.Text = ""; txtMinistryID.Text = ""; } else { txtMinistry.Text = ""; txtMinistryID.Text = ""; } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Ministries.aspx", "", "btnMinistryAdd_Click", ex.Message.ToString(), new ECGroupConnection()); throw; } }
public async Task <int> CreateAsync(string name, int addressId, string pictureLink, string url, int ministryCode) { var newMinistry = new Ministry { Name = name, AddressId = addressId, MinistryCode = (MinistryCode)ministryCode, PictureLink = pictureLink, Url = url, }; await this.ministriesRepository.AddAsync(newMinistry); await this.ministriesRepository.SaveChangesAsync(); return(newMinistry.Id); }
// GET: Ministries/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ministry ministry = db.Ministries.Find(id); if (ministry == null) { return(HttpNotFound()); } ViewBag.MinistrySizeId = new SelectList(db.MinistrySizes, "ID", "ID", ministry.MinistrySizeId); ViewBag.CountryId = new SelectList(db.Countries, "ID", "Name", ministry.CountryId); ViewBag.DenominationId = new SelectList(db.Denominations, "ID", "Type", ministry.DenominationId); ViewBag.MinistryCategoryId = new SelectList(db.MinistryCategories, "ID", "Name", ministry.MinistryCategoryId); return(View(ministry)); }
public async Task <Ministry> ToMinistryAsync(MinistryViewModel model, string path, bool isNew) { var ministry = new Ministry { // ChurchEvents = model.ChurchEvents, FollowUpHistories = model.FollowUpHistories, Id = isNew ? 0 : model.Id, ImageUrl = path, Name = model.Name, Admin = await _Context.Admins.FindAsync(model.AdminId), MinistryType = await _Context.MinistryTypes.FindAsync(model.MinistryTypeId) }; if (model.Id != 0) { ministry.Id = model.Id; } return(ministry); }
public Ministry Post(string Name, string NameEN, string ShortnameEN, string ShortnameTH) { var date = DateTime.Now; var counts = _context.Ministries.Count(); var Ministrydata = new Ministry { Name = Name, NameEN = NameEN, ShortnameEN = ShortnameEN, ShortnameTH = ShortnameTH, CreatedAt = date, Num = counts + 1 }; _context.Ministries.Add(Ministrydata); _context.SaveChanges(); return(Ministrydata); }
protected void gvMinistries_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { TransactionResult result; // Get the selected row's Ministry id int ministryIDToDelete = Convert.ToInt32(gvMinistries.DataKeys[e.RowIndex].Value); // Delete the selected Ministry _currentMinistry = new Ministry(); _currentMinistry.MinistryID = ministryIDToDelete; _currentMinistry.ScreenMode = ScreenMode.Delete; result = _currentMinistry.Commit(); // Display the status of the delete System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); // If successfully deleted, get the Ministry Details if (result.Status == TransactionStatus.Success) { GetMinistryDetails(); } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Ministries.aspx", "", "gvMinistries_RowDeleting", ex.Message.ToString(), new ECGroupConnection()); throw; } }