Beispiel #1
0
        public virtual async Task <ProductCheckoutAttributeModel> PrepareProductCheckoutAttributeModelAsync(TblProductCheckoutAttributes attribute, int productId)
        {
            ProductCheckoutAttributeModel result;

            if (attribute == null)
            {
                result = new ProductCheckoutAttributeModel();
            }
            else
            {
                result = attribute.Adapt <ProductCheckoutAttributeModel>();
                await attribute.LoadAllLocalizedStringsToModelAsync(result);
            }

            result.ProductId = productId;
            return(result);
        }
        public virtual async Task <ActionResult> Editor(ProductCheckoutAttributeModel model, bool?saveAndContinue)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var record   = _productCheckoutAttributeModelFactory.PrepareTblProductCheckoutAttributes(model);
            var recordId = model.Id;

            try
            {
                if (model.Id == null)
                {
                    //Add new record
                    recordId = await _productCheckoutAttributesService.AddAsync(record);
                }
                else
                {
                    //Edit record
                    await _productCheckoutAttributesService.UpdateAsync(record);
                }

                await _localizedEntityService.SaveAllLocalizedStringsAsync(record, model);
            }
            catch (Exception e)
            {
                var errorCode = ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(e, System.Web.HttpContext.Current));
                ModelState.AddModelError("", string.Format(_localizationService.GetResource("ErrorOnOperation"), e.Message, errorCode));
                return(View(model));
            }

            if (saveAndContinue != null && saveAndContinue.Value)
            {
                return(RedirectToAction("Editor", "ProductCheckoutAttributes", new { productId = record.ProductId, id = recordId }));
            }

            return(Content(@"<script language='javascript' type='text/javascript'>
                                window.close();
                                window.opener.refreshProductCheckoutAttributeGrid();
                             </script>"));
        }
Beispiel #3
0
        public virtual TblProductCheckoutAttributes PrepareTblProductCheckoutAttributes(ProductCheckoutAttributeModel attribute)
        {
            var result = attribute.Adapt <TblProductCheckoutAttributes>();

            return(result);
        }