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

            var record   = _modelFactory.PrepareTblProductDiscountsForUserGroups(model);
            var recordId = model.Id;

            try
            {
                if (model.Id == null)
                {
                    //Add new record
                    recordId = await _productDiscountsForUserGroupsService.AddAsync(record);
                }
                else
                {
                    //Edit record
                    await _productDiscountsForUserGroupsService.UpdateAsync(record);
                }
            }
            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", "ProductDiscountsForUserGroups", new { productId = record.ProductId, id = recordId }));
            }

            return(Content(@"<script language='javascript' type='text/javascript'>
                                window.close();
                                window.opener.refreshProductDiscountsForUserGroupsGrid();
                             </script>"));
        }
Exemple #2
0
        public virtual TblProductDiscountsForUserGroups PrepareTblProductDiscountsForUserGroups(ProductDiscountsForUserGroupsModel model)
        {
            var result = model.Adapt <TblProductDiscountsForUserGroups>();

            return(result);
        }