コード例 #1
0
ファイル: HostsController.cs プロジェクト: jangocheng/Sticky
        public async Task <HostReponse> List([FromQuery] int?id)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            if (user == null)
            {
                return new HostReponse()
                       {
                           Valid = false, Error = "No User Access"
                       }
            }
            ;
            try
            {
                HostReponse response = new HostReponse
                {
                    Valid  = true,
                    Result = (await _hostManager.GetUserHostsAsync(user.Email, id)).Select(c => new HostResult()
                    {
                        Owner                 = c.User.Email,
                        FinalizePage          = c.FinalizePage,
                        AdToCartId            = c.AddToCardId,
                        LogoOtherData         = c.LogoOtherData,
                        LogoAddress           = c.LogoAddress,
                        HostAddress           = c.HostAddress,
                        Id                    = c.Id,
                        ProductValidityType   = c.ProductValidityId,
                        UserValidityType      = c.UserValidityId,
                        SegmentCreationAccess = new SegmentCreationAccess()
                        {
                            Page         = c.HostValidated && c.PageValidated,
                            AddToCart    = c.AddToCardValidated,
                            Fav          = c.FavValidated == true,
                            Buy          = c.FinalizeValidated,
                            ProductVisit = c.CategoryValidated
                        }
                    })
                };

                return(response);
            }
            catch (Exception ex)
            {
                return(new HostReponse()
                {
                    Error = ex.Message, Valid = false
                });
            }
        }
コード例 #2
0
ファイル: HostsController.cs プロジェクト: jangocheng/Sticky
 public async Task <HostReponse> ListAll([FromQuery] string email)
 {
     try
     {
         HostReponse response = new HostReponse
         {
             Valid  = true,
             Result = (await _hostManager.GetAllHostsAsync(email)).Select(c => new HostResult()
             {
                 Owner                 = c.User.Email,
                 FinalizePage          = c.FinalizePage,
                 AdToCartId            = c.AddToCardId,
                 LogoOtherData         = c.LogoOtherData,
                 LogoAddress           = c.LogoAddress,
                 HostAddress           = c.HostAddress,
                 Id                    = c.Id,
                 ProductValidityType   = c.ProductValidityId,
                 UserValidityType      = c.UserValidityId,
                 SegmentCreationAccess = new SegmentCreationAccess()
                 {
                     Page         = c.HostValidated && c.PageValidated,
                     AddToCart    = c.AddToCardValidated,
                     Buy          = c.FinalizeValidated,
                     ProductVisit = c.CategoryValidated
                 }
             })
         };
         return(response);
     }
     catch (Exception ex)
     {
         return(new HostReponse()
         {
             Error = ex.Message, Valid = false
         });
     }
 }