Esempio n. 1
0
        public IHttpActionResult UpdateProjectMeeting(int projectId, int meetingId, ProjectMeetingCreate dto)
        {
            if (projectId != dto.ProjectId || meetingId != dto.MeetingId)
            {
                return(BadRequest("Invalid request"));
            }
            var meetingModel = new ProjectMeeting
            {
                MeetingId       = dto.MeetingId,
                ProjectId       = dto.ProjectId,
                MeetingDate     = dto.MeetingDate,
                MeetingTime     = dto.MeetingTime,
                Purpose         = dto.Purpose,
                Attendees       = dto.AttendeeIds,
                CreatedByUserId = base.UserId
            };

            Validate(meetingModel);

            if (ModelState.IsValid)
            {
                _repoFactory.ProjectMeetings.UpdateMeeting(meetingModel);
                return(Ok());
            }
            return(BadRequest(ModelState));
        }
Esempio n. 2
0
        public IHttpActionResult CreateProjectMeeting(int projectId, ProjectMeetingCreate dto)
        {
            var meetingModel = new ProjectMeeting
            {
                MeetingId       = dto.MeetingId,
                ProjectId       = dto.ProjectId,
                MeetingDate     = dto.MeetingDate,
                MeetingTime     = dto.MeetingTime,
                Purpose         = dto.Purpose,
                Attendees       = dto.AttendeeIds,
                CreatedByUserId = base.UserId
            };

            Validate(meetingModel);

            if (ModelState.IsValid)
            {
                var meetingId = _repoFactory.ProjectMeetings.CreateMeeting(meetingModel);
                if (meetingId.HasValue)
                {
                    dto.MeetingId = meetingId.Value;
                    return(Created($"/api/projects/{projectId}/meetings/{dto.MeetingId}", dto));
                }
                return(BadRequest("Meeting could not be created"));
            }
            return(BadRequest(ModelState));
        }
Esempio n. 3
0
        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 <ProjectMeeting> projectMeeting = new List <ProjectMeeting>();


            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/ProjectMeetings/{id}");

                if (Res.IsSuccessStatusCode)
                {
                    var            projectMeetingResponse = Res.Content.ReadAsStringAsync().Result;
                    ProjectMeeting myProjectMeeting       = JsonConvert.DeserializeObject <ProjectMeeting>(projectMeetingResponse);
                    return(View(myProjectMeeting));
                }
                else
                {
                    this.AddNotification("Unable to display Project Meeting information,please contact Administrator" + Res, NotificationType.ERROR);
                    return(View());
                }
            }
        }
Esempio n. 4
0
        public async Task <ActionResult> Edit([Bind(Include = "ID,MeetingTitle,MeetingDetails,MeetingPurpose,MeetingMedium,DiscussionSummary,MeetingMinutes,MeetingStatus,ProjectID,OrganizationID,CreatedDate,isDeleted,TimeStamp,UserId")] ProjectMeeting projectMeeting)
        {
            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/ProjectMeetings/{projectMeeting.ID}", projectMeeting);

                    if (Res.IsSuccessStatusCode)
                    {
                        this.AddNotification("Project Meeting information modified successfully", NotificationType.SUCCESS);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        this.AddNotification("Project Meeting information cannot be modified at this time. Please contact Administrator", NotificationType.ERROR);
                        return(View());
                    }
                }
            }
            ViewBag.OrganizationID = await OrganizationSelectListByModel(token, projectMeeting.OrganizationID);

            ViewBag.ProjectID = await ProjectSelectListByModel(token, projectMeeting.ProjectID);

            return(View(projectMeeting));
        }
Esempio n. 5
0
        public async Task <ActionResult> Create([Bind(Include = "ID,MeetingTitle,MeetingDetails,MeetingPurpose,MeetingMedium,DiscussionSummary,MeetingMinutes,MeetingStatus,ProjectID,OrganizationID,CreatedDate,isDeleted,TimeStamp,UserId")] ProjectMeeting projectMeeting)
        {
            #region USERVALIDATION
            token = (string)(Session["accessToken"]);
            string userID = (string)(Session["UserID"]);
            #endregion

            if (ModelState.IsValid)
            {
                projectMeeting.CreatedDate = DateTime.Now;
                projectMeeting.isDeleted   = false;
                projectMeeting.TimeStamp   = DateTime.Now;
                projectMeeting.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/ProjectMeetingss", projectMeeting);

                    if (Res.IsSuccessStatusCode)
                    {
                        this.AddNotification("Project Meeting created successfully", NotificationType.SUCCESS);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        this.AddNotification("Project Meeting cannot be created at this time. Please contact Administrator" + Res, NotificationType.ERROR);
                        return(View());
                    }
                }
            }


            ViewBag.OrganizationID = await OrganizationSelectListByModel(token, projectMeeting.OrganizationID);

            ViewBag.ProjectID = await ProjectSelectListByModel(token, projectMeeting.ProjectID);

            return(View(projectMeeting));
        }
Esempio n. 6
0
        private ProjectMeetingDto ConvertToMeetingDto(ProjectMeeting m)
        {
            var dto = new ProjectMeetingDto
            {
                MeetingId         = m.MeetingId,
                MeetingDate       = m.MeetingDate,
                MeetingTime       = m.MeetingTime,
                Purpose           = m.Purpose,
                AttendeeNames     = m.AttendeeIdsList?.Select(userId => _cacheService.GetUserName(userId)),//?.MergeStrings(),
                AttendeeIds       = m.AttendeeIdsList,
                CreatedByUserId   = m.CreatedByUserId,
                CreatedByUserName = _cacheService.GetUserName(m.CreatedByUserId),
                ProjectId         = m.ProjectId,
                ProjectName       = _cacheService.GetProjectName(m.ProjectId)
            };

            dto.AttendeeIdNames = m.AttendeeIdsList?
                                  .Zip(dto.AttendeeNames, (id, name) => new { id, name })
                                  .ToDictionary(s => s.id, s => s.name);
            return(dto);
        }