public IActionResult DisplayMembers() { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); SocialWorker socialWorker = _repo.SocialWorker.GetSocialWorkerByUserId(userId); var charts = _repo.Chart.GetChartsBySocialWorkerIdIncludeAll(socialWorker.Id).ToList(); List <Member> listOfMembersById = FilterMembersBySocialWorker(charts, socialWorker.Id).ToList(); return(View(listOfMembersById)); }
public Task <Enquiry> GetByReferenceId(Guid referenceId) { var entity = _enquiryDataProvider.GetEnquiry(referenceId).Result; if (entity == null) { return(null); } // else, convert db entity to web enquiry Enquiry enquiry = null; if (entity != null) { var actions = _enquiryDataProvider.GetActions(entity.Id); SocialWorker sw = new SocialWorker() { ForeName = entity.SwForeName, SurName = entity.SwSurName, EmailAddress = entity.SwEmailAddress, PhoneNumber = entity.SwPhoneNumber }; enquiry = new Enquiry() { ReferenceId = entity.ReferenceId, CareHomeId = entity.CareHomeId, ReferralAgencyId = entity.ReferralAgencyId, LocalAuthorityId = entity.LocalAuthorityId, ForeName = entity.ForeName, SurName = entity.SurName, MiddleName = entity.MiddleName, Dob = entity.Dob, Gender = entity.Gender, MaritalStatus = entity.MaritalStatus, SocialWorker = sw, CareCategoryId = entity.CareCategoryId, CareNeed = entity.CareNeed, StayType = entity.StayType, MoveInDate = entity.MoveInDate, FamilyHomeVisitDate = entity.FamilyHomeVisitDate, RoomLocation = entity.RoomLocation, RoomNumber = entity.RoomNumber, Comments = entity.Comments, Status = entity.Status, UpdatedBy = entity.UpdatedBy, UpdatedDate = entity.UpdatedDate, EnquiryActions = actions }; } return(Task.FromResult(enquiry)); }
public ActionResult DeleteUser(string id) { var db = new ApplicationDbContext(); try { SocialWorker worker = new SocialWorker(); worker.DeleteUser(id, ref db); } catch (Exception e) { return(Redirect("/Users/Show/" + id)); } string user_wall_route = "/"; return(Redirect(user_wall_route)); }
public IActionResult Create(SocialWorker socialWorker) { if (ModelState.IsValid) { try { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); socialWorker.IdentityUserId = userId; _repo.SocialWorker.CreateSocialWorker(socialWorker); _repo.Save(); } catch { return(View(socialWorker)); } } return(RedirectToAction(nameof(Index))); }
public ActionResult Delete(int id) { ApplicationDbContext db = new ApplicationDbContext(); try { Comment comm = db.Comments.Find(id); if (comm.UserId != User.Identity.GetUserId() && !User.IsInRole("Administrator") && !User.IsInRole("Editor")) { throw new Exception(); } int PostId = comm.PostId; SocialWorker worker = new SocialWorker(); worker.DeleteComment(id, ref db); return(RedirectToAction("Show", "Posts", new { id = PostId })); } catch (Exception) { return(RedirectToAction("Index", "Posts")); } }
public ActionResult Delete(int Id) { ApplicationDbContext db = new ApplicationDbContext(); try { Group group = db.Groups.Find(Id); var user = db.Users.Find(User.Identity.GetUserId()); if (group.UserId != user.Id && !User.IsInRole("Administrator")) { throw new Exception(); } SocialWorker worker = new SocialWorker(); worker.DeleteGroup(Id, ref db); } catch (Exception e) { TempData["message"] = "Group doesn't exist, or insuficient rights!"; return(Redirect("/Groups/Show/Id")); } return(Redirect("/Groups/")); }
public Task <Resident> Update(ResidentRequest resident) { var residentExisting = GetResident(resident.ReferenceId); if (residentExisting == null) { throw new ArgumentNullException(nameof(resident)); } var residentEntity = ConvertToResidentEntity(resident); residentEntity.Id = residentExisting.Id; // Contact Info. Issue: Contact info is separate table but Email and Phone comes as values // Need to find if already exists? if so update else insert.. var existingResidentContacts = _residentContactDataProvider.GetResidentContactsByResidentId(residentEntity.Id); // _residentDataProvider.GetResidentContactsByResidentId(residentEntity.Id); List <ResidentContact> rcs = new List <ResidentContact>(); if (existingResidentContacts.Any()) { // get existing email address or phone existingResidentContacts.ForEach((rc) => { if (!string.IsNullOrEmpty(rc.ContactType) && rc.ContactType == CONTACT_TYPE.email.ToString()) { rc.Id = rc.Id; rc.Data = resident.EmailAddress; } if (!string.IsNullOrEmpty(rc.ContactType) && rc.ContactType == CONTACT_TYPE.phone.ToString()) { rc.Id = rc.Id; rc.Data = resident.PhoneNumber; } rcs.Add(rc); }); } else { // No existing contacts found if (!string.IsNullOrEmpty(residentEntity.EmailAddress)) { ResidentContact rc = new ResidentContact() { ContactType = CONTACT_TYPE.email.ToString(), Data = residentEntity.EmailAddress }; rcs.Add(rc); } if (!string.IsNullOrEmpty(residentEntity.PhoneNumber)) { ResidentContact rc = new ResidentContact() { ContactType = CONTACT_TYPE.phone.ToString(), Data = residentEntity.PhoneNumber }; rcs.Add(rc); } } residentEntity.ResidentContacts = rcs.ToArray(); // SocialWorker Info. Issue: SW info is separate table SocialWorker swToBeUpdIns = new SocialWorker(); if (resident.SocialWorker != null && resident.SocialWorker.ForeName != "") { swToBeUpdIns.ForeName = resident.SocialWorker.ForeName; swToBeUpdIns.SurName = resident.SocialWorker.SurName; swToBeUpdIns.EmailAddress = resident.SocialWorker.EmailAddress; swToBeUpdIns.PhoneNumber = resident.SocialWorker.PhoneNumber; } // Need to find if already exists? if so update else insert.. SocialWorker existingSocialWorker = _socialWorkerDataProvider.GetSocialWorkerByResidentId(residentEntity.Id); //_residentDataProvider.GetSocialWorker(residentEntity.Id); if (existingSocialWorker != null) { swToBeUpdIns.Id = existingSocialWorker.Id; } residentEntity.SocialWorker = swToBeUpdIns; var residentEntityUpdated = _residentDataProvider.Update(residentEntity); // todo: return new resident... var residentCreated = new Resident() { ReferenceId = residentEntity.ReferenceId }; return(Task.FromResult(residentCreated)); }