public ActionResult Rooms_Destroy([DataSourceRequest]DataSourceRequest request, Room room)
        {
            if (ModelState.IsValid)
            {
                var entity = new Room
                {
                    Id = room.Id,
                    Context = room.Context,
                    Name = room.Name,
                    CreatorId = room.CreatorId,
                    MemberId = room.MemberId
                };

                db.Rooms.Attach(entity);
                db.Rooms.Remove(entity);
                db.SaveChanges();
            }

            return Json(new[] { room }.ToDataSourceResult(request, ModelState));
        }
Пример #2
0
        public string Create(RoomViewModel model, string userId)
        {
            var roomContext = Guid.NewGuid();
            var roomCreator = this.Users.GetById(userId);

            var room = new Room
            {
                Context = roomContext,
                Name = model.Name,
                CreatorId = roomCreator.Id
            };

            roomCreator.Rooms.Add(room);
            this.Users.Update(roomCreator);
            this.Users.SaveChanges();

            if (room.Id == 0)
            {
                return ServicesConstants.RoomCreationFailed;
            }

            return room.Name;
        }
Пример #3
0
 public void Update(Room entity)
 {
     this.Rooms.Update(entity);
 }