Esempio n. 1
0
        public IActionResult UpdatePostType(PostTypeDto postTypeDto)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var postType = _repository.PostType.FindByCondition(c => c.Id == postTypeDto.Id).FirstOrDefault();
                if (postType == null)
                {
                    return(NotFound());
                }
                postType.Title       = postTypeDto.Title;
                postType.Duration    = postTypeDto.Duration;
                postType.Description = postTypeDto.Description;
                postType.ApiUrl      = postTypeDto.ApiUrl;
                postType.Icon        = postTypeDto.Icon;
                postType.IsFree      = postTypeDto.IsFree;
                postType.Price       = postTypeDto.Price;
                postType.Rkey        = postTypeDto.Rkey;
                postType.Mdate       = DateTime.Now.Ticks;
                postType.MuserId     = ClaimPrincipalFactory.GetUserId(User);
                _repository.PostType.Update(postType);
                _repository.Save();

                return(NoContent());
            }
            catch (Exception e)
            {
                return(BadRequest("Internal Server Error"));
            }
        }
Esempio n. 2
0
 public PagesCountArgs(
     PostTypeDto postType,
     int perPage,
     PublishStatus publishStatus             = PublishStatus.Any,
     FrontPageStatus frontPageStatus         = FrontPageStatus.Any,
     ItemAvailableStatus itemAvailableStatus = ItemAvailableStatus.Any
     ) : this(postType, null, perPage, publishStatus, frontPageStatus, itemAvailableStatus)
 {
 }
Esempio n. 3
0
        public async Task <PostDto> GetPostByUrlAndTypeAsync(string url, PostTypeDto postType)
        {
            var args = new MethodArgs
            {
                { nameof(url), url },
                { "PostType.Id", postType.Id.ToString() }//TODO Canged Service
            };

            return(await PostRequestAsync <PostDto>(MethodNames.Posts.GetPostByUrlAndType, args));
        }
Esempio n. 4
0
 public PagesCountArgs(
     PostTypeDto postType,
     CategoryDto category,
     int perPage,
     PublishStatus publishStatus             = PublishStatus.Any,
     FrontPageStatus frontPageStatus         = FrontPageStatus.Any,
     ItemAvailableStatus itemAvailableStatus = ItemAvailableStatus.Any
     ) : base(publishStatus, frontPageStatus, itemAvailableStatus)
 {
     PostType = postType;
     Category = category;
     PerPage  = perPage;
 }
Esempio n. 5
0
 public PostsGetterArgs(
     Guid?categoryId,
     int page,
     int perPage,
     PostTypeDto postType,
     IEnumerable <CategoryDto> excludedCategories = null,
     bool sortByPublish                      = true,
     PublishStatus publishStatus             = PublishStatus.Any,
     FrontPageStatus frontPageStatus         = FrontPageStatus.Any,
     ItemAvailableStatus itemAvailableStatus = ItemAvailableStatus.Any
     ) : base(publishStatus, frontPageStatus, itemAvailableStatus)
 {
     CategoryId         = categoryId;
     Page               = page;
     PerPage            = perPage;
     PostType           = postType;
     ExcludedCategories = excludedCategories;
     SortByPublish      = sortByPublish;
 }
Esempio n. 6
0
 public IActionResult InsertPostType(PostTypeDto postTypeDto)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var postType = _mapper.Map <PostType>(postTypeDto);
         postType.Cdate   = DateTime.Now.Ticks;
         postType.CuserId = ClaimPrincipalFactory.GetUserId(User);
         _repository.PostType.Create(postType);
         _repository.Save();
         return(Created("", postType));
     }
     catch (Exception e)
     {
         return(BadRequest("Internal Server Error"));
     }
 }