Esempio n. 1
0
        public async Task EditGroupAsync(GroupServiceModel serviceModel)
        {
            var group = await this._data.Groups
                        .FirstOrDefaultAsync(i => i.GroupId == serviceModel.GroupId);

            group.Title       = serviceModel.Title;
            group.Description = serviceModel.Description;

            this._data.Update(group);
            await this._data.SaveChangesAsync();
        }
Esempio n. 2
0
        /// <summary>
        /// When a new group is saved in the db, get its auto generated id then create new UserInGroup record as the member is creator & admin.
        /// </summary>
        /// <param name="serviceModel"></param>
        /// <returns></returns>
        public async Task AddGroupAsync(GroupServiceModel serviceModel)
        {
            var group = new Group()
            {
                Title       = serviceModel.Title,
                Description = serviceModel.Description
            };

            await this._data.Groups.AddAsync(group);

            await this._data.SaveChangesAsync();

            var groupId = GetGroupIdByTitle(group.Title);

            await AddAdminAsync(groupId, serviceModel.AdminId);
        }