示例#1
0
        public ActionResult Delete(BookingChannelVM bookingChannelVM)
        {
            //Get BookingChannel
            BookingChannel bookingChannel = new BookingChannel();

            bookingChannel = bookingChannelRepository.BookingChannel(
                bookingChannelVM.BookingChannel.BookingChannelId
                );

            //Check Exists
            if (bookingChannel == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                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"));
            }

            //Delete Item
            try
            {
                bookingChannelRepository.Delete(bookingChannelVM.BookingChannel);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = String.Format("/BookingChannel.mvc/Delete/id={0}", bookingChannelVM.BookingChannel.BookingChannelId);
                    return(View("VersionError"));
                }
                //Generic Error
                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }

            //Return
            return(RedirectToAction("List", new { id = bookingChannel.ClientSubUnitGuid }));
        }
        //Update in DB
        public void Update(BookingChannelVM BookingChannelVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            //products to XML
            XmlDocument    doc = new XmlDocument();         // Create the XML Declaration, and append it to XML document
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);
            XmlElement root = doc.CreateElement("ContentBookedItems");

            doc.AppendChild(root);

            if (BookingChannelVM.ContentBookedItems != null)
            {
                if (BookingChannelVM.ContentBookedItems.Count > 0)
                {
                    XmlElement xmlContentBookedItems = doc.CreateElement("ContentBookedItems");
                    foreach (string p in BookingChannelVM.ContentBookedItems)
                    {
                        if (!string.IsNullOrEmpty(p))
                        {
                            XmlElement xmlContentBookedItem = doc.CreateElement("ContentBookedItem");
                            xmlContentBookedItem.InnerText = p;
                            xmlContentBookedItems.AppendChild(xmlContentBookedItem);
                        }
                    }
                    root.AppendChild(xmlContentBookedItems);
                }
            }

            db.spDesktopDataAdmin_UpdateClientSubUnitBookingChannel_v1(
                BookingChannelVM.BookingChannel.BookingChannelId,
                BookingChannelVM.BookingChannel.ClientSubUnitGuid,
                BookingChannelVM.BookingChannel.GDSCode,
                BookingChannelVM.BookingChannel.BookingChannelTypeId,
                BookingChannelVM.BookingChannel.ProductChannelTypeId,
                BookingChannelVM.BookingChannel.DesktopUsedTypeId,
                BookingChannelVM.BookingChannel.BookingPseudoCityOrOfficeId,
                BookingChannelVM.BookingChannel.TicketingPseudoCityOrOfficeId,
                System.Xml.Linq.XElement.Parse(doc.OuterXml),                 //ContentBookedItems
                adminUserGuid,
                BookingChannelVM.BookingChannel.VersionNumber
                );
        }
示例#3
0
        // GET: /Create
        public ActionResult Create(string id)
        {
            //Get ClientSubUnit
            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(id);

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

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

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

            BookingChannelVM bookingChannelVM = new BookingChannelVM();

            bookingChannelVM.ClientSubUnit = clientSubUnit;

            BookingChannel bookingChannel = new BookingChannel();

            bookingChannel.ClientSubUnit     = clientSubUnit;
            bookingChannel.ClientSubUnitGuid = clientSubUnit.ClientSubUnitGuid;
            bookingChannelVM.BookingChannel  = bookingChannel;

            //Usage Types
            UsageTypeRepository usageTypeRepository = new UsageTypeRepository();

            bookingChannelVM.UsageTypes = new SelectList(usageTypeRepository.GetAvailableUsageTypes(id).ToList(), "UsageTypeId", "UsageTypeDescription");

            //Booking Channel Types
            BookingChannelTypeRepository bookingChannelTypeRepository = new BookingChannelTypeRepository();

            bookingChannelVM.BookingChannelTypes = new SelectList(bookingChannelTypeRepository.GetAllBookingChannelTypes().ToList(), "BookingChannelTypeId", "BookingChannelTypeDescription");

            //Channel Products
            ProductChannelTypeRepository productChannelTypeRepository = new ProductChannelTypeRepository();

            bookingChannelVM.ProductChannelTypes = new SelectList(productChannelTypeRepository.GetAllProductChannelTypes().ToList(), "ProductChannelTypeId", "ProductChannelTypeDescription");

            //Desktop Used Types
            DesktopUsedTypeRepository desktopUsedTypeRepository = new DesktopUsedTypeRepository();

            bookingChannelVM.DesktopUsedTypes = new SelectList(desktopUsedTypeRepository.GetAllDesktopUsedTypes().ToList(), "DesktopUsedTypeId", "DesktopUsedTypeDescription");

            //Content Booked Items
            ProductRepository productRepository = new ProductRepository();

            bookingChannelVM.Products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName");

            GDSRepository GDSRepository = new GDSRepository();

            bookingChannelVM.GDSList = new SelectList(GDSRepository.GetAllGDSsExceptALL().OrderBy(x => x.GDSName).ToList(), "GDSCode", "GDSName");

            //Show Create Form
            return(View(bookingChannelVM));
        }
示例#4
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));
        }
示例#5
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));
        }
示例#6
0
        public ActionResult Edit(BookingChannelVM bookingChannelVM)
        {
            //Get BookingChannel
            BookingChannel bookingChannel = new BookingChannel();

            bookingChannel = bookingChannelRepository.BookingChannel(
                bookingChannelVM.BookingChannel.BookingChannelId
                );

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

            string clientSubUnitGuid = bookingChannelVM.BookingChannel.ClientSubUnitGuid;

            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(clientSubUnitGuid);

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

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

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

            //Update  Model from Form
            try
            {
                TryUpdateModel <BookingChannel>(bookingChannel, "BookingChannel");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }

            try
            {
                bookingChannelRepository.Update(bookingChannelVM);
            }
            catch (SqlException ex)
            {
                LogRepository logRepository = new LogRepository();
                logRepository.LogError(ex.Message);

                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }


            return(RedirectToAction("List", new { id = clientSubUnitGuid }));
        }
示例#7
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get BookingChannel
            BookingChannel bookingChannel = new BookingChannel();

            bookingChannel = bookingChannelRepository.BookingChannel(id);

            //Check Exists
            if (bookingChannel == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                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;


            //Booking Channel Types
            BookingChannelTypeRepository bookingChannelTypeRepository = new BookingChannelTypeRepository();

            if (bookingChannelVM.BookingChannel.BookingChannelTypeId != null)
            {
                bookingChannelVM.BookingChannelTypes = new SelectList(
                    bookingChannelTypeRepository.GetAllBookingChannelTypes().ToList(),
                    "BookingChannelTypeId",
                    "BookingChannelTypeDescription",
                    bookingChannelVM.BookingChannel.BookingChannelTypeId
                    );
            }
            else
            {
                bookingChannelVM.BookingChannelTypes = new SelectList(
                    bookingChannelTypeRepository.GetAllBookingChannelTypes().ToList(),
                    "BookingChannelTypeId",
                    "BookingChannelTypeDescription"
                    );
            }

            //Channel Products
            ProductChannelTypeRepository productChannelTypeRepository = new ProductChannelTypeRepository();
            int bookingChannelTypeId = (bookingChannelVM.BookingChannel.BookingChannelTypeId != null) ? bookingChannelVM.BookingChannel.BookingChannelTypeId.Value : 1;

            bookingChannelVM.ProductChannelTypes = new SelectList(
                productChannelTypeRepository.GetProductChannelTypesForBookingChannel(bookingChannelTypeId).ToList(),
                "ProductChannelTypeId",
                "ProductChannelTypeDescription",
                bookingChannelVM.BookingChannel.ProductChannelTypeId
                );

            //Desktop Used Types
            DesktopUsedTypeRepository desktopUsedTypeRepository = new DesktopUsedTypeRepository();

            if (bookingChannelVM.BookingChannel.DesktopUsedTypeId != null)
            {
                bookingChannelVM.DesktopUsedTypes = new SelectList(
                    desktopUsedTypeRepository.GetAllDesktopUsedTypes().ToList(),
                    "DesktopUsedTypeId",
                    "DesktopUsedTypeDescription",
                    bookingChannelVM.BookingChannel.DesktopUsedTypeId
                    );
            }
            else
            {
                bookingChannelVM.DesktopUsedTypes = new SelectList(
                    desktopUsedTypeRepository.GetAllDesktopUsedTypes().ToList(),
                    "DesktopUsedTypeId",
                    "DesktopUsedTypeDescription"
                    );
            }

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

            ProductRepository            productRepository = new ProductRepository();
            IEnumerable <SelectListItem> defaultProducts   = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName");

            List <SelectListItem> contentBookedItemsSelected = new List <SelectListItem>();

            foreach (SelectListItem item in defaultProducts)
            {
                bool selected = false;

                foreach (ContentBookedItem contentBookedItem in contentBookedItems)
                {
                    if (item.Value == contentBookedItem.Product.ProductId.ToString())
                    {
                        selected = true;
                    }
                }

                contentBookedItemsSelected.Add(
                    new SelectListItem()
                {
                    Text     = item.Text,
                    Value    = item.Value,
                    Selected = selected
                }
                    );
            }

            bookingChannelVM.ContentBookedItemsSelected = contentBookedItemsSelected;

            //GDS
            GDSRepository GDSRepository = new GDSRepository();

            bookingChannelVM.GDSList = new SelectList(GDSRepository.GetAllGDSsExceptALL().OrderBy(x => x.GDSName).ToList(), "GDSCode", "GDSName");

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