Example #1
0
        public ActionResult Delete(int id)
        {
            //Get BookingChannel
            BookingChannel bookingChannel = new BookingChannel();

            bookingChannel = bookingChannelRepository.BookingChannel(id);

            //Check Exists
            if (bookingChannel == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Access Rights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToClientSubUnit(bookingChannel.ClientSubUnitGuid) || !hierarchyRepository.AdminHasDomainWriteAccess(groupName))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            BookingChannelVM bookingChannelVM = new BookingChannelVM();

            bookingChannelVM.BookingChannel = bookingChannel;

            //Get ClientSubUnit
            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(bookingChannel.ClientSubUnitGuid);
            bookingChannelVM.ClientSubUnit = clientSubUnit;

            //Get GDS
            GDSRepository gdsRepository = new GDSRepository();
            GDS           gds           = gdsRepository.GetGDS(bookingChannel.GDSCode);

            bookingChannelVM.GDS = gds;

            //Channel Products
            if (bookingChannel.ProductChannelTypeId != null)
            {
                ProductChannelTypeRepository productChannelTypeRepository = new ProductChannelTypeRepository();
                ProductChannelType           productChannelType           = productChannelTypeRepository.GetProductChannelType((int)bookingChannel.ProductChannelTypeId);
                if (productChannelType != null)
                {
                    bookingChannelVM.BookingChannel.ProductChannelType = productChannelType;
                }
            }

            //Desktop Used Types
            if (bookingChannel.DesktopUsedTypeId != null)
            {
                DesktopUsedTypeRepository desktopUsedTypeRepository = new DesktopUsedTypeRepository();
                DesktopUsedType           desktopUsedType           = desktopUsedTypeRepository.GetDesktopUsedType((int)bookingChannel.DesktopUsedTypeId);
                if (desktopUsedType != null)
                {
                    bookingChannelVM.BookingChannel.DesktopUsedType = desktopUsedType;
                }
            }

            //Content Booked Items
            ContentBookedItemRepository contentBookedItemRepository = new ContentBookedItemRepository();
            List <ContentBookedItem>    contentBookedItems          = contentBookedItemRepository.GetBookingChannelContentBookedItems(bookingChannel.BookingChannelId).ToList();

            if (contentBookedItems != null)
            {
                bookingChannelVM.ContentBookedItemsList = String.Join(", ", contentBookedItems.Select(x => x.Product.ProductName.ToString()).ToArray());
            }

            //Show Form
            return(View(bookingChannelVM));
        }
Example #2
0
        // GET: /View
        public ActionResult View(int id)
        {
            //Get BookingChannel
            BookingChannel bookingChannel = new BookingChannel();

            bookingChannel = bookingChannelRepository.BookingChannel(id);

            //Check Exists
            if (bookingChannel == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            BookingChannelVM bookingChannelVM = new BookingChannelVM();

            bookingChannelVM.BookingChannel = bookingChannel;

            //Get ClientSubUnit
            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(bookingChannel.ClientSubUnitGuid);
            bookingChannelVM.ClientSubUnit = clientSubUnit;

            //Get GDS
            GDSRepository gdsRepository = new GDSRepository();
            GDS           gds           = gdsRepository.GetGDS(bookingChannel.GDSCode);

            bookingChannelVM.GDS = gds;

            //Channel Products
            if (bookingChannel.ProductChannelTypeId != null)
            {
                ProductChannelTypeRepository productChannelTypeRepository = new ProductChannelTypeRepository();
                ProductChannelType           productChannelType           = productChannelTypeRepository.GetProductChannelType((int)bookingChannel.ProductChannelTypeId);
                if (productChannelType != null)
                {
                    bookingChannelVM.BookingChannel.ProductChannelType = productChannelType;
                }
            }

            //Desktop Used Types
            if (bookingChannel.DesktopUsedTypeId != null)
            {
                DesktopUsedTypeRepository desktopUsedTypeRepository = new DesktopUsedTypeRepository();
                DesktopUsedType           desktopUsedType           = desktopUsedTypeRepository.GetDesktopUsedType((int)bookingChannel.DesktopUsedTypeId);
                if (desktopUsedType != null)
                {
                    bookingChannelVM.BookingChannel.DesktopUsedType = desktopUsedType;
                }
            }

            //Content Booked Items
            ContentBookedItemRepository contentBookedItemRepository = new ContentBookedItemRepository();
            List <ContentBookedItem>    contentBookedItems          = contentBookedItemRepository.GetBookingChannelContentBookedItems(bookingChannel.BookingChannelId).ToList();

            if (contentBookedItems != null)
            {
                bookingChannelVM.ContentBookedItemsList = String.Join(", ", contentBookedItems.Select(x => x.Product.ProductName.ToString()).ToArray());
            }

            //Show Form
            return(View(bookingChannelVM));
        }