public async Task <JsonResult> AddPersonId(int id, int type, Guid sessionid)
        {
            ActivityLogPersonModel person = await ActivityService.FindPersonById(id);

            if (person == null)
            {
                return(Json(new
                {
                    Success = false,
                    Message = "Person not found"
                }));
            }

            ActivityLogParticipantModel participant = new ActivityLogParticipantModel()
            {
                Person = person,
                Type   = (ActivityLogParticipantTypes)type
            };

            ActivityService.AddParticipantToSession(Session, sessionid, participant);

            return(Json(new
            {
                Success = true,
                Message = string.Empty
            }));
        }
        public async Task <JsonResult> RemovePersonId(int id, Guid sessionId)
        {
            ActivityLogPersonModel person = await ActivityService.FindPersonById(id);

            if (person == null)
            {
                return(Json(new
                {
                    Success = false,
                    Message = "Person not found"
                }));
            }

            ActivityLogParticipantModel participant = new ActivityLogParticipantModel()
            {
                Person = person
            };

            ActivityService.RemoveParticipantFromSession(Session, sessionId, participant);

            return(Json(new
            {
                Success = true,
                Message = string.Empty
            }));
        }
Example #3
0
        public void RemoveParticipantFromSession(HttpSessionStateBase session, Guid sessionId,
                                                 ActivityLogParticipantModel participant)
        {
            List <ActivityLogParticipantModel> participants = (session[ParticipantsSessionName] as Dictionary <Guid, ActivityLogSessionModel>)[sessionId].WorkingList;

            int index = participants.FindIndex(x => x.Person.Id == participant.Person.Id);

            participants.RemoveAt(index);
        }
        public async Task <JsonResult> AddPerson(ActivityLogPersonCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    int id = await ActivityService.CreatePerson(model);

                    ActivityLogParticipantModel participant = new ActivityLogParticipantModel()
                    {
                        Person = new ActivityLogPersonModel()
                        {
                            Id          = id,
                            FullName    = model.FullName,
                            PhoneNumber = model.PhoneNumber,
                            Description = model.Description,
                            Email       = model.Email,
                            SessionId   = model.SessionId
                        },
                        Type = (ActivityLogParticipantTypes)model.Type
                    };

                    ActivityService.AddParticipantToSession(Session, model.SessionId, participant);

                    return(Json(new
                    {
                        Success = true,
                        Message = string.Empty,
                        Id = id
                    }));
                }
                catch (Exception e)
                {
                    MvcApplication.LogException(e);
                    return(Json(new
                    {
                        Success = false,
                        Message = "There was an error saving. It has been logged for later review.",
                        Id = 0
                    }));
                }
            }

            return(Json(new
            {
                Success = false,
                Message = "Invalid form",
                Id = 0
            }));
        }
Example #5
0
 public void AddParticipantToSession(HttpSessionStateBase session, Guid sessionId,
                                     ActivityLogParticipantModel participant)
 {
     (session[ParticipantsSessionName] as Dictionary <Guid, ActivityLogSessionModel>)[sessionId].WorkingList.Add(participant);
 }