Esempio n. 1
0
 public static void EnsureValid(this Core.Product product, UpdateProductEntity updateProductEntity)
 {
     if (product == null)
     {
         throw new BaseException(Convert.ToInt32(ErrorCode.ProductNotFound()), Error.ProductNotFound(updateProductEntity.Id), null, HttpStatusCode.NotFound);
     }
 }
Esempio n. 2
0
        public async Task <UpdateProductEntity> UpdateProductAsync(UpdateProductEntity updateProductEntity)
        {
            Core.Product product  = updateProductEntity.ToEntity();
            var          response = await product.UpdateAsync(_productStore);

            response.EnsureValid(updateProductEntity);
            return(response.ToResponseModel());
        }
        public static Core.Product ToEntity(this UpdateProductEntity updateProductEntity)
        {
            var product = new Core.Product(updateProductEntity.Price.ToEntity(), updateProductEntity.SellerId, updateProductEntity.Name)
            {
                Id             = updateProductEntity.Id,
                Description    = updateProductEntity.Description,
                HeroImage      = updateProductEntity.HeroImage,
                Category       = updateProductEntity.Category.ToEntity(),
                Images         = updateProductEntity.Images,
                PurchasedDate  = updateProductEntity.PurchasedDate,
                PickupAddress  = updateProductEntity.PickupAddress.ToEntity(),
                PostDateTime   = updateProductEntity.PostDateTime,
                ExpirationDate = updateProductEntity.ExpirationDate,
                Status         = updateProductEntity.Status.ToEntity()
            };

            return(product);
        }
        public static UpdateProductEntity ToResponseModel(this Core.Product product)
        {
            UpdateProductEntity response = new UpdateProductEntity()
            {
                Id             = product.Id,
                SellerId       = product.SellerId,
                Name           = product.Name,
                Description    = product.Description,
                HeroImage      = product.HeroImage,
                Price          = product.Price.ToModel(),
                Category       = product.Category.ToModel(),
                Status         = product.Status.ToModel(),
                PostDateTime   = product.PostDateTime,
                ExpirationDate = product.ExpirationDate,
                Images         = product.Images,
                PurchasedDate  = product.PurchasedDate,
                PickupAddress  = product.PickupAddress.ToModel()
            };

            return(response);
        }
Esempio n. 5
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.OrderedProduct);
            RecieptDTO user = JsonConvert.DeserializeObject <RecieptDTO>(Intent.GetStringExtra("RecieptData"));
            //var extras = Intent.GetParcelableExtra("RecieptData") ?? String.Empty;
            string textRecieptName = user.Name;

            textRecieptID = user.RecieptID.ToString();
            TextView txtRecieptName     = FindViewById <TextView>(Resource.Id.recieptTxt);
            TextView txtProductName     = FindViewById <TextView>(Resource.Id.editProductName);
            TextView txtProductQuantity = FindViewById <TextView>(Resource.Id.editProductQuantity);

            txtRecieptName.Text = textRecieptName;
            SessionHelper sessionHelper = new SessionHelper(this);
            string        Username      = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY);
            string        UserID        = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY);
            string        AuthToken     = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY);

            JsonValue jsonProduct = await HttpRequestHelper <ProductEntity> .GetRequest(ServiceTypes.GetProducts, "/" + AuthToken + "/" + textRecieptID);

            ParseRecieptJSON(jsonProduct);

            Button SendReceiptToCustomer = FindViewById <Button>(Resource.Id.btnSendReceiptToCustomer);
            Button UpdateSubTotal        = FindViewById <Button>(Resource.Id.btnUpdateOrderAmount);

            UpdateSubTotal.Click        += UpdateSubTotal_Click;
            SendReceiptToCustomer.Click += async(sender, e) => {
                UpdateProductEntity updateProductEntity = new UpdateProductEntity {
                    AuthToken = AuthToken, productInfo = GetProductsData()
                };
                JsonValue json = await HttpRequestHelper <UpdateProductEntity> .POSTreq(ServiceTypes.UpdateProductAvailability, updateProductEntity);

                ParseJSON(json);
            };
        }