示例#1
0
        public virtual JsonResult ExportDiscounts([FromBody] OneCAuth model)
        {
            if (model == null)
            {
                return(Json(new OneCResponse()
                {
                    Success = false, Message = "JSON format is incorrect."
                }));
            }

            var response = IsLogin(model?.Username, model?.Email, model?.Password);

            if (response.Success)
            {
                var customer = _customerSettings.UsernamesEnabled
                    ? _customerService.GetCustomerByUsername(model.Username)
                    : _customerService.GetCustomerByEmail(model.Email);

                //activity log
                _customerActivityService.InsertActivity(customer, "PublicStore.1C.ExportDiscounts.Login", "1C Exporting discount begin.");

                var discounts = _exportManager.ExportDiscountsToOneC();
                response.Total = discounts.Item1;

                if (discounts.Item2.Count() > 0)
                {
                    response.Data = discounts.Item2;
                }
                else
                {
                    response.Success = false;
                    response.Message = "Does not have any discount.";
                }

                //activiti log
                _customerActivityService.InsertActivity(customer, "PublicStore.1C.ExportDiscounts.LogOut", "1C Exporting discount end.");
            }
            return(Json(response));
        }