Example #1
0
        public async Task SaveAsync()
        {
            try
            {
                using (var _context = new UnitOfWorkLid())
                {
                    var allTitles = await AdvTitlesBussines.GetAllAsync(Guid);

                    if (!AdvTitlesBussines.RemoveAll(allTitles))
                    {
                        return;
                    }
                    var allImg = await AdvPicturesBussines.GetAllAsync(Guid);

                    if (!AdvPicturesBussines.RemoveAll(allImg))
                    {
                        return;
                    }
                    var allCon = await AdvContentBussines.GetAllAsync(Guid);

                    if (!AdvContentBussines.RemoveAll(allCon))
                    {
                        return;
                    }

                    var a   = Mappings.Default.Map <Advertise>(this);
                    var res = _context.Advertise.Save(a);
                    _context.Set_Save();
                    _context.Dispose();
                }
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }
Example #2
0
        public async Task SaveAsync(List <AdvTitlesBussines> lstTitles, List <AdvPicturesBussines> lstImg, List <AdvContentBussines> lstCon)
        {
            try
            {
                using (var _context = new UnitOfWorkLid())
                {
                    var allTitles = await AdvTitlesBussines.GetAllAsync(Guid);

                    if (!AdvTitlesBussines.RemoveAll(allTitles))
                    {
                        return;
                    }
                    var allImg = await AdvPicturesBussines.GetAllAsync(Guid);

                    if (!AdvPicturesBussines.RemoveAll(allImg))
                    {
                        return;
                    }
                    var allCon = await AdvContentBussines.GetAllAsync(Guid);

                    if (!AdvContentBussines.RemoveAll(allCon))
                    {
                        return;
                    }

                    if (lstTitles.Count > 0)
                    {
                        var a1 = Mappings.Default.Map <List <AdvTitles> >(lstTitles);
                        foreach (var item in a1)
                        {
                            var res1 = _context.AdvTitles.Save(item);
                            _context.Set_Save();
                        }
                    }

                    if (lstImg.Count > 0)
                    {
                        var a1 = Mappings.Default.Map <List <AdvPictures> >(lstImg);
                        foreach (var item in a1)
                        {
                            var res1 = _context.AdvPictures.Save(item);
                            _context.Set_Save();
                        }
                    }


                    if (lstCon.Count > 0)
                    {
                        var a1 = Mappings.Default.Map <List <AdvContent> >(lstCon);
                        foreach (var item in a1)
                        {
                            var res1 = _context.AdvContents.Save(item);
                            _context.Set_Save();
                        }
                    }

                    var a   = Mappings.Default.Map <Advertise>(this);
                    var res = _context.Advertise.Save(a);
                    _context.Set_Save();
                    _context.Dispose();
                }
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }