//[ValidateAntiForgeryToken] //public ActionResult Create([Bind(Include = "MeetingAttendanceID,MeetingDate,LiaisonIDs,MeetingTypeID,MeetingSubjectID,CommunityID,DistrictID,CommiteeMemberID,StartTime,EndTime,Duration,Notes,IsActive")] MeetingAttendance meetingAttendance) //{ public JsonResult Create(MeetingAttendance meetingAttendance) { string message = ""; var valid = TryUpdateModel(meetingAttendance); if (valid == true) { db.MeetingAttendances.Add(meetingAttendance); meetingAttendance.IsActive = true; meetingAttendance.CreatedBy = 1; meetingAttendance.CreatedOn = DateTime.Now; meetingAttendance.ModifiedOn = DateTime.Now; try { db.SaveChanges(); message = "Meetings Attended details saved successfully."; } catch (Exception ex) { valid = false; message = "Error occurred while saving Meeting Attendance."; } } return(Json(new { Valid = valid, Message = message, Errors = GetErrorsFromModelState() }, JsonRequestBehavior.AllowGet)); }
// GET: MeetingAttendances/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MeetingAttendance meetingAttendance = db.MeetingAttendances.Find(id); if (meetingAttendance == null) { return(HttpNotFound()); } List <Liaisons> list = db.Liaisons.ToList(); List <Liaisons> SelectedList = new List <Liaisons>(); foreach (Liaisons l in list) { if (meetingAttendance.LiaisonIDs.Contains(l.LiaisonID.ToString())) { l.IsChecked = true; } else { l.IsChecked = false; } SelectedList.Add(l); } ViewBag.Liaisions = list.Select(a => new SelectListItem { Text = a.LiaisonName, Value = a.LiaisonID.ToString(), Selected = a.IsChecked }); return(View(meetingAttendance)); }
public async Task <ActionResult> Details(int?id) { #region USERVALIDATION token = (string)(Session["accessToken"]); string userID = (string)(Session["UserID"]); #endregion if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } List <MeetingAttendance> meetingAttendance = new List <MeetingAttendance>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); HttpResponseMessage Res = await client.GetAsync($"api/MeetingAttendances/{id}"); if (Res.IsSuccessStatusCode) { var meetingAttendanceResponse = Res.Content.ReadAsStringAsync().Result; MeetingAttendance myMeetingAttendance = JsonConvert.DeserializeObject <MeetingAttendance>(meetingAttendanceResponse); return(View(myMeetingAttendance)); } else { this.AddNotification("Unable to display Meeting Attendance information,please contact Administrator" + Res, NotificationType.ERROR); return(View()); } } }
public ActionResult Index() { DataTable dt = new System.Data.DataTable(); dt = MeetingAttendance.GetMeetingAttendanceList(); return(View(dt)); }
public async Task <ActionResult> Edit([Bind(Include = "ID,FullName,Designation,EmailAddress,PhoneNumber,AttendanceStatus,ProjectMeetingID,ProjectID,ProjectTeamID,CreatedDate,isDeleted,TimeStamp,OrganizationID,UserId")] MeetingAttendance meetingAttendance) { if (ModelState.IsValid) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); HttpResponseMessage Res = await client.PutAsJsonAsync($"api/MeetingAttendances/{meetingAttendance.ID}", meetingAttendance); if (Res.IsSuccessStatusCode) { this.AddNotification("Meeting Attendance information modified successfully", NotificationType.SUCCESS); return(RedirectToAction("Index")); } else { this.AddNotification("Meeting Attendance information cannot be modified at this time. Please contact Administrator", NotificationType.ERROR); return(View()); } } } ViewBag.OrganizationID = await OrganizationSelectListByModel(token, meetingAttendance.OrganizationID); ViewBag.ProjectID = await ProjectSelectListByModel(token, meetingAttendance.ProjectID); ViewBag.ProjectMeetingID = await ProjectMeetingSelectListByModel(token, meetingAttendance.ProjectMeetingID); return(View(meetingAttendance)); }
public ActionResult DeleteConfirmed(int id) { MeetingAttendance meetingAttendance = db.MeetingAttendances.Find(id); db.MeetingAttendances.Remove(meetingAttendance); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <MeetingAttendance> Create(MeetingAttendance entity) { var MeetingAttendance = _repositoryMeetingAttendance.FirstOrDefault(x => x.Id == entity.Id); if (MeetingAttendance != null) { throw new UserFriendlyException("Already Exist"); } else { return(await _repositoryMeetingAttendance.InsertAsync(entity)); } }
// GET: MeetingAttendances/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MeetingAttendance meetingAttendance = db.MeetingAttendances.Find(id); if (meetingAttendance == null) { return(HttpNotFound()); } return(View(meetingAttendance)); }
private async Task <bool> CreateMeetingAttendance(NewMeeting newMeeting, int meetingId) { foreach (Attendance s in newMeeting.Attendance) { var entity = new MeetingAttendance { MeetingId = meetingId, UserId = s.UserId }; _context.MeetingAttendances.Add(entity); } var saveResult = await _context.SaveChangesAsync(); return(saveResult != 0); }
public async Task <ActionResult> Create([Bind(Include = "ID,FullName,Designation,EmailAddress,PhoneNumber,AttendanceStatus,ProjectMeetingID,ProjectID,ProjectTeamID,CreatedDate,isDeleted,TimeStamp,OrganizationID,UserId")] MeetingAttendance meetingAttendance) { #region USERVALIDATION token = (string)(Session["accessToken"]); string userID = (string)(Session["UserID"]); #endregion if (ModelState.IsValid) { meetingAttendance.CreatedDate = DateTime.Now; meetingAttendance.isDeleted = false; meetingAttendance.TimeStamp = DateTime.Now; meetingAttendance.UserId = userID; using (var client = new HttpClient()) { client.BaseAddress = new Uri(baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); HttpResponseMessage Res = await client.PostAsJsonAsync("api/MeetingAttendances", meetingAttendance); if (Res.IsSuccessStatusCode) { this.AddNotification("Meeting Attendance created successfully", NotificationType.SUCCESS); return(RedirectToAction("Index")); } else { this.AddNotification("Meeting Attendance cannot be created at this time. Please contact Administrator" + Res, NotificationType.ERROR); return(View()); } } } ViewBag.OrganizationID = await OrganizationSelectListByModel(token, meetingAttendance.OrganizationID); ViewBag.ProjectID = await ProjectSelectListByModel(token, meetingAttendance.ProjectID); ViewBag.ProjectMeetingID = await ProjectMeetingSelectListByModel(token, meetingAttendance.ProjectMeetingID); return(View(meetingAttendance)); }
public int UpdateMeeting(MeetingDTO objDTO, string userId) { Meeting meetingObject = new Meeting(); objDTO.MeetingNumber = _repository.Query().SelectQueryable().Where(c => c.MeetingDate.Year == objDTO.MeetingDate.Year && c.Id != objDTO.Id).Any() ? _repository.Query().SelectQueryable().Where(c => c.MeetingDate.Year == objDTO.MeetingDate.Year && c.Id != objDTO.Id).Max(c => c.MeetingNumber) + 1 : 1; try { _unitOfWork.BeginTransaction(); meetingObject = _repository .Query() .SelectQueryable().Where(c => c.Id == objDTO.Id).FirstOrDefault(); objDTO.RoundId = _roundRepository.Query().SelectQueryable().Where(c => c.CouncilTypeId == objDTO.CouncilTypeId && c.IsCurrent).FirstOrDefault().Id; var meetingCounsilmembers = _meetingAttendanceRepository.Query().SelectQueryable().Where(c => c.MeetingId == meetingObject.Id && c.MemberType == (int)EnumMemberType.CouncilMember).Select(c => new { key = c.Id, value = c.CouncilMemberId.Value }).ToList(); foreach (var member in meetingCounsilmembers) { if (!objDTO.SelectedCouncilMembers.ToList().Contains(member.value)) { _meetingAttendanceRepository.Delete(member.key); } } _unitOfWork.SaveChanges(); var meetingEmployeeMembers = _meetingAttendanceRepository.Query().SelectQueryable().Where(c => c.MeetingId == meetingObject.Id && c.MemberType == (int)EnumMemberType.Employee).Select(c => new { key = c.Id, value = c.EmployeId }).ToList(); foreach (var member in meetingEmployeeMembers) { if (!objDTO.SelectedEmployees.Select(c => c.Id).ToList().Contains(Convert.ToInt32(member.value))) { _meetingAttendanceRepository.Delete(member.key); } } var ExternalMembers = _meetingAttendanceRepository.Query().SelectQueryable().Where(c => c.MeetingId == meetingObject.Id && c.MemberType == (int)EnumMemberType.External).Select(c => c.Id).ToList(); foreach (var member in ExternalMembers) { if (!objDTO.MeetingAttendances.Select(c => c.Id).ToList().Contains(member)) { _meetingAttendanceRepository.Delete(member); } } _unitOfWork.SaveChanges(); objDTO.MeetingAttendances.ToList().ForEach(c => { var temp = new MeetingAttendance(); Mapper.Map <MeetingAttendanceDTO, MeetingAttendance>(c, temp); temp.MeetingId = meetingObject.Id; temp.MemberType = (int)EnumMemberType.External; if (c.Id != 0) { //_meetingAttendanceRepository.Update(temp); } else { _meetingAttendanceRepository.Insert(temp); } }); _unitOfWork.SaveChanges(); objDTO.SelectedCouncilMembers.ToList().ForEach(c => { if (!meetingCounsilmembers.Select(cm => cm.value).Contains(c)) { var councilMember = _councilMemberBLL.GetById(c); meetingObject.MeetingAttendances.Add(new MeetingAttendance() { CouncilMemberId = councilMember.Id, Name = councilMember.Name, MemberType = (int)EnumMemberType.CouncilMember }); } }); objDTO.SelectedEmployees.ToList().ForEach(c => { if (!meetingEmployeeMembers.Select(emp => Convert.ToInt32(emp.value)).Contains(c.Id)) { meetingObject.MeetingAttendances.Add(new MeetingAttendance() { Name = c.Name, EmployeId = c.Id.ToString(), DepartmentId = c.DepartmentId, DepartmentName = c.DepartmentName, MemberType = (int)EnumMemberType.Employee }); } }); _unitOfWork.SaveChanges(); Mapper.Map <MeetingDTO, Meeting>(objDTO, meetingObject); meetingObject.TrackingState = TrackableEntities.TrackingState.Modified; foreach (var agendaItem in meetingObject.AgendaItems) { if (agendaItem.Id == 0) { agendaItem.TrackingState = TrackableEntities.TrackingState.Added; } else { agendaItem.TrackingState = TrackableEntities.TrackingState.Modified; } if (agendaItem.AgendaDetails.Any()) { foreach (var agendaDetail in agendaItem.AgendaDetails) { if (agendaDetail.Id == 0) { agendaDetail.TrackingState = TrackableEntities.TrackingState.Added; } else { agendaDetail.TrackingState = TrackableEntities.TrackingState.Modified; } } } } meetingObject.MeetingAttendances.ToList().ForEach(c => c.TrackingState = TrackableEntities.TrackingState.Modified); meetingObject.Round = _roundRepository.Query().SelectQueryable().Where(c => c.CouncilTypeId == objDTO.CouncilTypeId && c.IsCurrent).FirstOrDefault(); base.InsertOrUpdateGraph(meetingObject); if (_unitOfWork.SaveChanges() > 0) { objDTO.AgendaItems.Where(c => c.AttachementName != "").ToList().ForEach(c => { var agendanewfile = CopyAttachment( userId, c.AttachementName, meetingObject.Id, meetingObject.AgendaItems.Where(d => d.AgendaNumber == c.AgendaNumber).FirstOrDefault().Id , null); if (!String.IsNullOrEmpty(agendanewfile)) { meetingObject .AgendaItems .Where(d => d.AgendaNumber == c.AgendaNumber).FirstOrDefault() .AttachementName = agendanewfile; } var adendaItemId = meetingObject.AgendaItems.Where(item => item.AgendaNumber == c.AgendaNumber).FirstOrDefault().Id; c.AgendaDetails.ToList().ForEach(d => { var returnedVal = CopyAttachment( userId, d.AttachementName, meetingObject.Id, adendaItemId, meetingObject.AgendaItems.Where(f => f.Id == adendaItemId).SelectMany(y => y.AgendaDetails).Where(det => det.TreeNumber == d.TreeNumber).FirstOrDefault().Id); if (!String.IsNullOrEmpty(returnedVal)) { meetingObject.AgendaItems.Where(f => f.Id == adendaItemId).SelectMany(y => y.AgendaDetails).Where(det => det.TreeNumber == d.TreeNumber).FirstOrDefault() .AttachementName = returnedVal; } }); _unitOfWork.SaveChanges(); }); } _unitOfWork.Commit(); return(meetingObject.Id); } catch (Exception ex) { _unitOfWork.Rollback(); throw ex; } }
public int InsertMeeting(MeetingDTO objDTO, string userId) { Meeting meetingObject = new Meeting(); objDTO.MeetingIndexNumber = _repository.Query().SelectQueryable().Max(c => c.MeetingIndexNumber) + 1; objDTO.MeetingNumber = _repository.Query().SelectQueryable().Where(c => c.MeetingDate.Year == objDTO.MeetingDate.Year).Any() ? _repository.Query().SelectQueryable().Where(c => c.MeetingDate.Year == objDTO.MeetingDate.Year).Max(c => c.MeetingNumber) + 1 : 1; try { _unitOfWork.BeginTransaction(); objDTO.RoundId = _roundRepository.Query().SelectQueryable().Where(c => c.CouncilTypeId == objDTO.CouncilTypeId && c.IsCurrent).FirstOrDefault().Id; Mapper.Map <MeetingDTO, Meeting>(objDTO, meetingObject); //operationObject.RefernceNo = GenerateRefernceNo(operationObject); objDTO.MeetingAttendances.ToList().ForEach(c => { MeetingAttendance externalattendence = new MeetingAttendance(); Mapper.Map <MeetingAttendanceDTO, MeetingAttendance>(c, externalattendence); externalattendence.MemberType = (int)EnumMemberType.External; meetingObject.MeetingAttendances.Add(externalattendence); }); //meetingObject.MeetingAttendances.ToList().ForEach(c => c.MemberType = (int)EnumMemberType.External); objDTO.SelectedCouncilMembers.ToList().ForEach(c => { var councilMember = _councilMemberBLL.GetById(c); meetingObject.MeetingAttendances.Add(new MeetingAttendance() { CouncilMemberId = councilMember.Id, Name = councilMember.Name, MemberType = (int)EnumMemberType.CouncilMember, Email = councilMember.Email, }); }); objDTO.SelectedEmployees.ToList().ForEach(c => { var emp = _employeeService.GetById(c.Id); meetingObject.MeetingAttendances.Add(new MeetingAttendance() { Name = c.Name, EmployeId = c.Id.ToString(), DepartmentId = c.DepartmentId, DepartmentName = c.DepartmentName, MemberType = (int)EnumMemberType.Employee, Email = emp.Email, }); }); base.Insert(meetingObject); if (_unitOfWork.SaveChanges() > 0) { objDTO.AgendaItems.Where(c => c.AttachementName != "").ToList().ForEach(c => { meetingObject .AgendaItems .Where(d => d.AgendaNumber == c.AgendaNumber).FirstOrDefault() .AttachementName = CopyAttachment( userId, c.AttachementName, meetingObject.Id, meetingObject.AgendaItems.Where(d => d.AgendaNumber == c.AgendaNumber).FirstOrDefault().Id , null); var adendaItemId = meetingObject.AgendaItems.Where(item => item.AgendaNumber == c.AgendaNumber).FirstOrDefault().Id; c.AgendaDetails.ToList().ForEach(d => { meetingObject.AgendaItems.Where(f => f.Id == adendaItemId).SelectMany(y => y.AgendaDetails).Where(det => det.TreeNumber == d.TreeNumber).FirstOrDefault() .AttachementName = CopyAttachment( userId, d.AttachementName, meetingObject.Id, adendaItemId, meetingObject.AgendaItems.Where(f => f.Id == adendaItemId).SelectMany(y => y.AgendaDetails).Where(det => det.TreeNumber == d.TreeNumber).FirstOrDefault().Id); }); _unitOfWork.SaveChanges(); }); } _unitOfWork.Commit(); return(meetingObject.Id); } catch (Exception ex) { _unitOfWork.Rollback(); throw ex; } }
public void Update(MeetingAttendance entity) { _repositoryMeetingAttendance.Update(entity); }