예제 #1
0
        /// <summary>
        /// 根据现有的房间代码信息,构造房间关联的楼座楼层信息
        /// </summary>
        /// <param name="sysCodeList"></param>
        /// <param name="roomCodeList"></param>
        /// <returns></returns>
        private List <GalleryDto> BuildGalleryList(List <SystemCodeInfo> sysCodeList, List <RoomSymbolInfo> roomCodeList)
        {
            var galleryCodeInfo = roomCodeList.Select(x => x.GalleryCode).Distinct().ToList();
            var sysGalleryInfo  = sysCodeList.Where(x => x.SysCodeType == SystemCodeTypes.ROOM_GALLERY_CODE).ToList();

            List <GalleryDto> galleryList = new List <GalleryDto>();

            foreach (var code in galleryCodeInfo)
            {
                var result = sysGalleryInfo.Where(x => x.SysCode == code).FirstOrDefault();
                if (result != null)
                {
                    GalleryDto gallery = new GalleryDto();
                    gallery.Code = code;
                    gallery.Name = result.SysCodeName;

                    var floorCodeInfo = roomCodeList.Where(x => x.GalleryCode == code).Select(x => x.FloorCode).ToList();
                    var sysFloorInfo  = sysCodeList.Where(x => x.SysCodeType == SystemCodeTypes.ROOM_FLOOR_CODE).ToList();
                    //获取关联的楼层信息列表
                    var floorList = sysFloorInfo.Where(x => floorCodeInfo.Contains(x.SysCode))
                                    .Select(x => new FloorDto
                    {
                        Code        = x.SysCode,
                        Name        = x.SysCodeName,
                        GalleryCode = code,
                    }).ToList();


                    gallery.FloorList = floorList.OrderBy(x => x.Code).ToList();
                    galleryList.Add(gallery);
                }
            }
            return(galleryList.OrderBy(x => x.Code).ToList());
        }
예제 #2
0
 public void copy(Gallery gallery1, GalleryDto gallery1Dto)
 {
     gallery1.description = gallery1Dto.description;
     gallery1.gallery_id  = gallery1Dto.gallery_id;
     gallery1.is_active   = gallery1Dto.is_active;
     gallery1.name        = gallery1Dto.name;
 }
        public JsonResult Update(GalleryDto dto)
        {
            dto.GalleryType = (int)GalleryFlag.Product;
            var res = _galleryContract.Update(dto);

            return(Json(res));
        }
        public IActionResult edit(GalleryModel model, IFormFile file)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    GalleryDto galleryDto = new GalleryDto();
                    galleryDto.gallery_id  = model.gallery_id;
                    galleryDto.name        = model.name;
                    galleryDto.description = model.description;

                    if (file != null)
                    {
                        galleryDto.name = _fileHelper.saveImageAndGetFileName(file, model.name);
                    }

                    galleryDto.is_active = model.is_active;

                    _galleryService.update(galleryDto);
                    AlertHelper.setMessage(this, "Gallery updated successfully.", messageType.success);
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
            }
            return(View(model));
        }
예제 #5
0
        public ActionResult <Gallery> PostGallery([FromBody] GalleryDto galleryDto)
        {
            var  gallery = this._mapper.Map <Gallery>(galleryDto);
            var  userId  = Convert.ToInt32(this.User.FindFirst(ClaimTypes.NameIdentifier).Value);
            User user    = this._userService.GetUser(userId);

            this._galleryService.AddGallery(user, gallery);
            return(this.Ok());
        }
예제 #6
0
        public async Task WhenICallGalleryService_AndMapToPhotosAlbums_IGetCorrectPhotos()
        {
            _albumService.Setup(x => x.GetAlbums()).ReturnsAsync(MockAlbums());
            _photoService.Setup(x => x.GetPhotos()).ReturnsAsync(MockPhotos());
            _galleryService = new GalleryService(_albumService.Object, _photoService.Object);
            GalleryDto gallery = await _galleryService.GetGallery();

            Assert.AreEqual(1, gallery.Albums.Where(x => x.Id == 1).Select(p => p.Photos.Count).First());
            Assert.AreEqual(2, gallery.Albums.Where(x => x.Id == 2).Select(p => p.Photos.Count).First());
            Assert.AreEqual(1, gallery.Albums.Where(x => x.Id == 3).Select(p => p.Photos.Count).First());
        }
예제 #7
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public async Task <GalleryDto> GetGalleryAsync(
            IndexParams param,
            int?categoryId   = null,
            string lang      = Language.KEY_fa_IR,
            bool isComponent = false)
        {
            param.CheckArgumentIsNull(nameof(param));
            var postType = await _postTypeRepository
                           .GetBySlugAsync(PostType.GALLERY);

            if (postType == null)
            {
                throw new PostTypeNotFoundException();
            }

            var query = _repository
                        .Query()
                        .IncludeFiles()
                        .Where(_ => _.PostTypeId == postType.Id)
                        .Where(_ => _.Status == PostStatus.Published)
                        .Where(_ => _.PublishDate <= _dateService.UtcNow())
                        .Where(_ => _.Language.LangKey == lang)
                        .Where(_ => _.IsComponent == isComponent);

            if (categoryId.HasValue)
            {
                query = query.Where(_ => _.CategoryId == categoryId);
            }

            query = query.SetOrder(param.OrderBy, !param.OrderDesc);

            if (param.HasPaging)
            {
                query = query
                        .Skip(param.Skip)
                        .Take(param.Take);
            }

            var queryResult = await query.ToListAsync();

            var result = new GalleryDto {
                Posts = queryResult.Adapt <List <PostFileGalleryDto> >()
            };

            foreach (var post in result.Posts)
            {
                post.Files = queryResult.FirstOrDefault(_ => _.Id == post.Id)
                             .PostFiles.OrderBy(_ => _.OrderNum)
                             .Select(_ => _.File)
                             .Adapt <List <PostFileGalleryItemDto> >();
            }

            return(await Task.FromResult(result));
        }
예제 #8
0
        public async Task <GalleryDto> GetGallery()
        {
            GalleryDto gallery = new GalleryDto();

            gallery.Albums = await _albumService.GetAlbums();

            List <PhotoDto> photos = await _photoService.GetPhotos();

            foreach (var album in gallery.Albums)
            {
                album.Photos = photos.Where(x => x.AlbumId == album.Id).ToList();
            }

            return(gallery);
        }
예제 #9
0
        public void AddPhotos(GalleryDto galleryDto, params PhotoDto[] photos)
        {
            Gallery gallery = this.Get(galleryDto.Id);

            foreach (var photo in photos)
            {
                if (gallery.Photos.Any(x => x.PhotoId == photo.Id))
                {
                    continue;
                }
                gallery.Photos.Add(new GalleryPhotos {
                    Gallery = gallery, PhotoId = photo.Id
                });
            }

            this._context.SaveChanges();
        }
 public void save(GalleryDto gallery1Dto)
 {
     try
     {
         using (TransactionScope txe = new TransactionScope(TransactionScopeOption.Required))
         {
             var gallery = new Gallery();
             _galleryMaker.copy(gallery, gallery1Dto);
             _galleryRepository.insert(gallery);
             txe.Complete();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #11
0
        /// <summary>
        /// Persist this gallery object to the data store.
        /// </summary>
        public void Save()
        {
            bool isNew = IsNew;

            using (var repo = new GalleryRepository())
            {
                if (IsNew)
                {
                    var galleryDto = new GalleryDto {
                        Description = Description, DateAdded = CreationDate
                    };
                    repo.Add(galleryDto);
                    repo.Save();
                    _id = galleryDto.GalleryId;
                }
                else
                {
                    var galleryDto = repo.Find(GalleryId);

                    if (galleryDto != null)
                    {
                        galleryDto.Description = Description;
                        repo.Save();
                    }
                    else
                    {
                        throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId));
                    }
                }
            }

            // For new galleries, configure it and then trigger the created event.
            if (isNew)
            {
                Configure();

                EventHandler <GalleryCreatedEventArgs> galleryCreated = GalleryCreated;
                if (galleryCreated != null)
                {
                    galleryCreated(null, new GalleryCreatedEventArgs(GalleryId));
                }
            }

            Factory.ClearAllCaches();
        }
예제 #12
0
        /// <summary>
        /// Persist this gallery instance to the data store.
        /// </summary>
        public void Save()
        {
            bool isNew = IsNew;

            using (var repo = new GalleryRepository())
            {
                if (IsNew)
                {
                    var galleryDto = new GalleryDto {
                        Description = Description, DateAdded = CreationDate
                    };
                    repo.Add(galleryDto);
                    repo.Save();
                    _id = galleryDto.GalleryId;
                }
                else
                {
                    var galleryDto = repo.Find(GalleryId);

                    if (galleryDto != null)
                    {
                        galleryDto.Description = Description;
                        repo.Save();
                    }
                    else
                    {
                        throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId));
                    }
                }
            }

            // For new galleries, configure it and then trigger the created event.
            if (isNew)
            {
                Validate();

                Factory.ClearGalleryCache(); // Needed so LoadGalleries(), called by AddDefaultRolesToRoleAlbumTable(), pulls new gallery from data store

                AddDefaultRolesToRoleAlbumTable();
            }

            Factory.ClearAllCaches();
        }
예제 #13
0
        public override OperationResult execute(CimetEntities entities)
        {
            GalleryDto dto = new GalleryDto();
            IEnumerable <PictureDto> iePictures =
                from galerija in entities.gallery
                select new PictureDto
            {
                Alt = galerija.picture.alt,
                Src = galerija.picture.src
            };

            dto.Pictures = iePictures.ToList();

            OperationResult result = new OperationResult();

            result.Status   = true;
            result.Items    = new BaseDto[1];
            result.Items[0] = dto;
            return(result);
        }
        public IActionResult add(GalleryModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    GalleryDto galleryDto = new GalleryDto();
                    galleryDto.name        = model.name;
                    galleryDto.description = model.description;
                    _galleryService.save(galleryDto);

                    AlertHelper.setMessage(this, "Gallery saved successfully.", messageType.success);
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
            }
            return(View(model));
        }
        public ActionResult Create(GalleryDto dto)
        {
            dto.GalleryType = (int)GalleryFlag.Product;
            if (!string.IsNullOrEmpty(dto.Attributes))
            {
                string[]   arrAttrId = dto.Attributes.Split(',');
                List <int> listId    = new List <int>();
                foreach (string strId in arrAttrId)
                {
                    if (!string.IsNullOrEmpty(strId))
                    {
                        listId.Add(int.Parse(strId));
                    }
                }
                var attrs = _galleryAttrContract.GalleryAttributes.Where(x => listId.Contains(x.Id));
                dto.GalleryAttributes = attrs.ToList();
            }
            var result = _galleryContract.Insert(dto);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #16
0
 public async Task UpsertGallery(GalleryDto input)
 {
     try
     {
         var obj = input.MapTo <Gallery>();
         if (input.Id == 0)
         {
             obj.IsDeleted    = false;
             obj.CreatedBy    = AbpSession.UserId;
             obj.DateCreated  = DateTime.Now;
             obj.DateModified = null;
         }
         else
         {
             obj.ModifiedBy   = AbpSession.UserId;
             obj.DateModified = DateTime.Now;
         }
         await _galleryRepository.InsertOrUpdateAsync(obj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void update(GalleryDto gallery1Dto)
        {
            try
            {
                using (TransactionScope txe = new TransactionScope(TransactionScopeOption.Required))
                {
                    Gallery gallery1 = _galleryRepository.getById(gallery1Dto.gallery_id);

                    if (gallery1 == null)
                    {
                        throw new ItemNotFoundException($"gallery with ID {gallery1Dto.gallery_id} doesnot Exit.");
                    }

                    _galleryMaker.copy(gallery1, gallery1Dto);
                    _galleryRepository.update(gallery1);;
                    txe.Complete();
                }
            }

            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Persist the specified gallery to the data store. Return the ID of the gallery.
        /// </summary>
        /// <param name="gallery">An instance of <see cref="IGallery"/> to persist to the data store.</param>
        /// <returns>
        /// Return the ID of the gallery. If this is a new gallery and a new ID has been
        /// assigned, then this value has also been assigned to the <see cref="IGallery.GalleryId"/> property.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="gallery" /> is null.</exception>		/// 
        public override int Gallery_Save(IGallery gallery)
        {
            if (gallery == null)
                throw new ArgumentNullException("gallery");

            using (GspContext ctx = new GspContext())
            {
                if (gallery.IsNew)
                {
                    GalleryDto galleryDto = new GalleryDto { Description = gallery.Description, DateAdded = gallery.CreationDate };

                    ctx.Galleries.Add(galleryDto);
                    ctx.SaveChanges();

                    // Assign newly created gallery ID.
                    gallery.GalleryId = galleryDto.GalleryId;
                }
                else
                {
                    var galleryDto = ctx.Galleries.Find(gallery.GalleryId);

                    if (galleryDto != null)
                    {
                        galleryDto.Description = gallery.Description;
                        ctx.SaveChanges();
                    }
                    else
                    {
                        throw new DataException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", gallery.GalleryId));
                    }
                }
            }

            return gallery.GalleryId;
        }
예제 #19
0
        public JsonResult Update(GalleryDto dto)
        {
            var res = _galleryContract.Update(dto);

            return(Json(res));
        }
예제 #20
0
        public ActionResult Create(GalleryDto dto)
        {
            var result = _galleryContract.Insert(dto);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #21
0
        public bool AddGallery(GalleryDto dataDto)
        {
            if (dataDto != null)
            {
                using (EcommerceDB context = new EcommerceDB())
                {
                    if (dataDto.Id <= 0)
                    {
                        Gallery AddData = new Gallery();
                        AddData.Name = dataDto.Name;
                        if (dataDto.Img1 != null && dataDto.Img1 != "" && AddData.Img1 != dataDto.Img1 && !dataDto.Img1.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img1.Substring(dataDto.Img1.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            AddData.Img1 = string.Concat("UploadedFiles\\" + id + ".jpg");
                        }
                        if (dataDto.Img2 != null && dataDto.Img2 != "" && AddData.Img2 != dataDto.Img2 && !dataDto.Img2.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img1.Substring(dataDto.Img2.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            AddData.Img2 = string.Concat("UploadedFiles\\" + id + ".jpg");
                        }

                        AddData.IsActive = true;
                        context.Gallerys.Add(AddData);
                        context.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        var olddata = context.Gallerys.FirstOrDefault(x => x.Id == dataDto.Id);
                        if (olddata != null)
                        {
                            olddata.Name = dataDto.Name;
                            if (dataDto.Img1 != null && dataDto.Img1 != "" && olddata.Img1 != dataDto.Img1 && !dataDto.Img1.Contains("http"))
                            {
                                Guid   id      = Guid.NewGuid();
                                var    imgData = dataDto.Img1.Substring(dataDto.Img1.IndexOf(",") + 1);
                                byte[] bytes   = Convert.FromBase64String(imgData);
                                Image  image;
                                using (MemoryStream ms = new MemoryStream(bytes))
                                {
                                    image = Image.FromStream(ms);
                                }
                                Bitmap b        = new Bitmap(image);
                                string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                                b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                                olddata.Img1 = string.Concat("UploadedFiles\\" + id + ".jpg");
                                context.Entry(olddata).Property(x => x.Img1).IsModified = true;
                            }
                        }
                        if (dataDto.Img2 != null && dataDto.Img2 != "" && olddata.Img2 != dataDto.Img2 && !dataDto.Img2.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img2.Substring(dataDto.Img2.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            olddata.Img2 = string.Concat("UploadedFiles\\" + id + ".jpg");
                            context.Entry(olddata).Property(x => x.Img2).IsModified = true;
                        }
                        olddata.IsActive = true;
                        context.Entry(olddata).Property(x => x.Name).IsModified = true;

                        context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                        olddata.IsActive = true;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #22
0
 public GalleryViewModel(GalleryDto output)
 {
     output.MapTo(this);
 }