Example #1
0
        public override bool Update(IConnectionHandler connectionHandler, Hall obj)
        {
            var bo     = new ChairBO();
            var oldobj = this.Get(connectionHandler, obj.Id);

            if (obj.Width != oldobj.Width || obj.Length != oldobj.Length)
            {
                var allowDelete = bo.AllowDelete(connectionHandler, obj.Id);
                if (!allowDelete)
                {
                    throw new Exception(Resources.Reservation.ErrrorInEditHallBecauseItHasReservedChair);
                }
                if (!this.DeleteChairs(connectionHandler, obj.Id))
                {
                    throw new Exception(Resources.Reservation.ErrorInSaveHall);
                }

                if (!this.AddNewChairs(connectionHandler, obj))
                {
                    throw new Exception(Resources.Reservation.ErrorInSaveHall);
                }
            }
            if (!base.Update(connectionHandler, obj))
            {
                throw new Exception(Resources.Reservation.ErrorInSaveHall);
            }
            return(true);
        }
Example #2
0
        public override bool Delete(IConnectionHandler connectionHandler, params object[] keys)
        {
            var obj         = this.Get(connectionHandler, keys);
            var allowDelete = new ChairBO().AllowDelete(connectionHandler, obj.Id);

            if (!allowDelete)
            {
                throw new Exception(Resources.Reservation.ErrorInDeleteHallBecauseItHasRservedChair);
            }
            var filter = this.Any(connectionHandler, x => x.ParentId == obj.Id);

            if (filter)
            {
                throw new Exception(Resources.Reservation.ErrorInDeleteHallBecauseItHasChildHall);
            }
            if (!this.DeleteChairs(connectionHandler, obj.Id))
            {
                throw new Exception(Resources.Reservation.ErrorInDeleteHall);
            }
            if (!this.DeleteChairtypes(connectionHandler, obj.Id))
            {
                throw new Exception(Resources.Reservation.ErrorInDeleteHall);
            }
            return(base.Delete(connectionHandler, keys));
        }
Example #3
0
        public override bool Delete(IConnectionHandler connectionHandler, params object[] keys)
        {
            var obj            = this.Get(connectionHandler, keys);
            var hasInChairType = new ChairBO().HasInChairType(connectionHandler, obj.Id);

            if (hasInChairType)
            {
                throw new Exception("صندلی با  این نوع صندلی وجود دارد و قابل حذف نمیباشد");
            }
            return(base.Delete(connectionHandler, keys));
        }
Example #4
0
        public bool AddNewChairs(IConnectionHandler connectionHandler, Hall obj)
        {
            var bo    = new ChairBO();
            var count = obj.Length * obj.Width;

            if (count <= 0)
            {
                return(true);
            }
            short column = 1;
            var   list   = new List <Chair>();

            for (int r = 1; r <= count / obj.Length; r++)
            {
                for (int c = 1; c <= obj.Length; c++)
                {
                    if (column <= count)
                    {
                        var chair = new Chair()
                        {
                            Id          = Guid.NewGuid(),
                            HallId      = obj.Id,
                            Column      = c,
                            Row         = r,
                            ChairTypeId = null,
                            Number      = 0,
                            Status      = (byte)Enums.ReservStatus.None
                        };
                        list.Add(chair);
                    }
                    column++;
                }
            }
            if (!bo.InsertChairs(connectionHandler, list))
            {
                throw new Exception(Resources.Reservation.ErrorInSaveHall);
            }
            return(true);
        }