Exemplo n.º 1
0
        /// <summary>
        /// Прикрепить файлы к заявке
        /// </summary>
        /// <param name="AttachId"></param>
        /// <param name="HelpDeskId"></param>
        /// <returns></returns>
        private HelpDeskAttachment AddAttachToHelpDesk(int AttachFsId, int HelpDeskId)
        {
            if (AttachFsId > 0 && HelpDeskId > 0)
            {
                using (MarketBotDbContext db = new MarketBotDbContext())
                {
                    HelpDeskAttachment attachment = new HelpDeskAttachment
                    {
                        AttachmentFsId = AttachFsId,
                        HelpDeskId     = HelpDeskId
                    };


                    db.HelpDeskAttachment.Add(attachment);

                    db.SaveChanges();
                    return(attachment);
                }
            }

            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Добавить файл к заявке
        /// </summary>
        /// <param name="AttachFsId"></param>
        /// <param name="HelpDeskId"></param>
        /// <returns></returns>
        public static HelpDeskAttachment AddAttachToHelpDesk(int AttachFsId, int HelpDeskId)
        {
            MarketBotDbContext db = new MarketBotDbContext();

            try
            {
                if (AttachFsId > 0 && HelpDeskId > 0)
                {
                    HelpDeskAttachment attachment = new HelpDeskAttachment
                    {
                        AttachmentFsId = AttachFsId,
                        HelpDeskId     = HelpDeskId
                    };

                    db.HelpDeskAttachment.Add(attachment);
                    db.SaveChanges();
                    return(attachment);
                }

                else
                {
                    return(null);
                }
            }

            catch
            {
                return(null);
            }

            finally
            {
                db.Dispose();
            }
        }