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
            }));
        }
Esempio n. 3
0
        public async Task <int> CreatePerson(ActivityLogPersonCreateViewModel createModel)
        {
            ActivityLogPersonModel model = new ActivityLogPersonModel()
            {
                FullName    = createModel.FullName,
                Email       = Formatter.SanitizeEmail(createModel.Email),
                Description = createModel.Description,
                PhoneNumber = createModel.PhoneNumber,
                SessionId   = createModel.SessionId
            };

            return(await ActivityLogPersonRepository.CreatePerson(model));
        }
Esempio n. 4
0
        public async Task <int> CreatePerson(ActivityLogPersonModel model)
        {
            const string sql = @"
                INSERT INTO [dbo].[ActivityLogPerson]
                ([FullName], [Description], [Phone], [Email])
                OUTPUT INSERTED.Id
                VALUES
                (@FullName, @Description, @PhoneNumber, @Email)";

            try
            {
                return((await UnitOfWork.Context().QueryAsync <int>(sql, model)).Single());
            }
            catch (Exception e)
            {
                e.Data["SQL"] = sql;
                ErrorStore.LogException(e, HttpContext.Current);
                throw e;
            }
        }