Exemplo n.º 1
0
        public ResponseViewModel Get(int id)
        {
            var response = new ResponseViewModel();

            var pictureGroup = _pictureGroupDal.GetPictureGroup(p => p.Id == id);

            if (pictureGroup == null)
            {
                response.IsSuccess = false;
                response.Message   = "PictureGroup bulunamadı.";
                return(response);
            }

            var pictureGroupDto = new PictureGroupDto()
            {
                Id           = pictureGroup.Id,
                PictureImage = pictureGroup.PictureImage,
                CreateDate   = pictureGroup.CreateDate,
                CreatedBy    = pictureGroup.CreatedBy,
                ModifyDate   = pictureGroup.ModifyDate,
                ModifiedBy   = pictureGroup.ModifiedBy,
                IsDeleted    = pictureGroup.IsDeleted,
            };

            response.Data = pictureGroupDto;

            return(response);
        }
        public IActionResult Edit(PictureGroupDto pictureGroupDto)
        {
            var response = new ResponseViewModel();

            response = _pictureGroupService.Update(pictureGroupDto);

            if (!response.IsSuccess)
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
Exemplo n.º 3
0
        public ResponseViewModel Update(PictureGroupDto pictureGroupDto)
        {
            var response = new ResponseViewModel();

            if (pictureGroupDto.CreatedBy != null)
            {
                var createdBy = IsUserHave((int)pictureGroupDto.CreatedBy);
                if (!createdBy)
                {
                    response.IsSuccess = false;
                    response.Message   = "createdBy User tablosunda bulunamadı ";

                    return(response);
                }
            }

            if (pictureGroupDto.ModifiedBy != null)
            {
                var modifiedBy = IsUserHave((int)pictureGroupDto.ModifiedBy);
                if (!modifiedBy)
                {
                    response.IsSuccess = false;
                    response.Message   = "ModifiedBy User tablosunda bulunamadı ";

                    return(response);
                }
            }

            var pictureGroup = new PictureGroup()
            {
                Id           = pictureGroupDto.Id,
                PictureImage = pictureGroupDto.PictureImage,
                CreateDate   = DateTime.Now,
                CreatedBy    = pictureGroupDto.CreatedBy,
                ModifyDate   = pictureGroupDto.ModifyDate,
                ModifiedBy   = pictureGroupDto.ModifiedBy,
                IsDeleted    = pictureGroupDto.IsDeleted
            };

            _pictureGroupDal.Update(pictureGroup);
            var saving = _pictureGroupDal.SaveChanges();

            if (!saving)
            {
                response.IsSuccess = false;
                response.Message   = "PictureGroup güncellenirken bir hata oluştu";
                response.Data      = pictureGroup;
            }

            return(response);
        }
Exemplo n.º 4
0
        public ResponseViewModel Add(PictureGroupDto pictureGroupDto)
        {
            var response = new ResponseViewModel();

            if (pictureGroupDto.CreatedBy != null)
            {
                var createdBy = IsUserHave((int)pictureGroupDto.CreatedBy);
                if (!createdBy)
                {
                    response.IsSuccess = false;
                    response.Message   = "createdBy User tablosunda bulunamadı ";

                    return(response);
                }
            }

            var pictureGroup = new PictureGroup()
            {
                PictureImage = pictureGroupDto.PictureImage,
                CreateDate   = DateTime.Now,
                CreatedBy    = pictureGroupDto.CreatedBy,
            };

            _pictureGroupDal.Add(pictureGroup);
            var saving = _pictureGroupDal.SaveChanges();

            if (!saving)
            {
                response.IsSuccess = false;
                response.Message   = "PictureGroup kaydedilirken bir hata oluştu";
                response.Data      = pictureGroup;
            }

            response.Data = "Id : " + pictureGroup.Id;

            return(response);
        }