Ejemplo n.º 1
0
        protected override void DeleteChildEntities(string[] childEntityList, string parentID)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */

                case "Container":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        ContainerLibrary        containerLibrary = new ContainerLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Container> resultList       = containerLibrary.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (Container continer in resultList)
                        {
                            string errorMsg;
                            if (containerLibrary.IsRefExits(continer.ID, out errorMsg))
                            {
                                throw new Exception(errorMsg);
                            }
                            containerLibrary.Delete(continer.ID.ToString());
                        }
                    }
                    break;

                case "BookingNotes":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        BookingNotesLibrary        BookingNotesLibrary = new BookingNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <BookingNotes> resultList          = BookingNotesLibrary.GetAllByParentID(Convert.ToInt32(parentID));
                        foreach (BookingNotes BookingNote in resultList)
                        {
                            BookingNotesLibrary.Delete(BookingNote.ID.ToString());
                        }
                    }
                    break;

                case "BookingAttachments":
                    if (Convert.ToInt32(parentID) > 0)
                    {
                        BookingAttachmentsLibrary        bookingAttachmentLibrary = new BookingAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <BookingAttachments> resultList = bookingAttachmentLibrary.GetAllByParentID(Convert.ToInt32(parentID));

                        foreach (BookingAttachments bookingAttachment in resultList)
                        {
                            bookingAttachmentLibrary.Delete(bookingAttachment.ID.ToString());
                        }
                    }
                    break;

                    #endregion
                }
            }
        }
Ejemplo n.º 2
0
        protected override void SaveChildEntities(string[] childEntityList, Booking entity)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */

                case "Container":
                    if (Session[ChildEntity] != null)
                    {
                        ContainerLibrary        containerLibrary = new ContainerLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <Container> resultList       = (IList <Container>)Session[ChildEntity];
                        foreach (Container continer in resultList)
                        {
                            continer.Booking = new Booking {
                                ID = entity.ID
                            };
                            containerLibrary.Add(continer);
                        }
                    }
                    break;

                case "BookingNotes":
                    if (Session[ChildEntity] != null)
                    {
                        BookingNotesLibrary        BookingNotesLibrary = new BookingNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <BookingNotes> resultList          = (IList <BookingNotes>)Session[ChildEntity];
                        foreach (BookingNotes BookingNote in resultList)
                        {
                            BookingNote.Parent = new Booking {
                                ID = entity.ID
                            };
                            //itemNote.Notes = System.Web.HttpUtility.HtmlDecode(itemNote.Notes);
                            BookingNotesLibrary.Add(BookingNote);
                        }
                    }
                    break;

                case "BookingAttachments":
                    if (Session[ChildEntity] != null)
                    {
                        BookingAttachmentsLibrary        BookingLibrary = new BookingAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <BookingAttachments> resultList     = (IList <BookingAttachments>)Session[ChildEntity];
                        string      destinationPath;
                        string      sourcePath;
                        FilelHelper fileHelper = new FilelHelper();
                        foreach (BookingAttachments Booking in resultList)
                        {
                            destinationPath       = fileHelper.GetSourceDirByFileRefId(Booking.Document_RefId.ToString());     // Path.Combine(Configuration.GetsmARTDocPath(), Booking.Document_RefId.ToString());
                            sourcePath            = fileHelper.GetTempSourceDirByFileRefId(Booking.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTTempDocPath(), Booking.Document_RefId.ToString());
                            Booking.Document_Path = fileHelper.GetFilePath(sourcePath);
                            fileHelper.MoveFile(Booking.Document_Name, sourcePath, destinationPath);

                            Booking.Parent = new Booking {
                                ID = entity.ID
                            };
                            BookingLibrary.Add(Booking);
                        }
                    }
                    break;

                    #endregion
                }
            }
        }