Beispiel #1
0
        public async Task <OmsJsonResult> CreateSubscribe(SubscriberFormData subscriberFormData)
        {
            JsonReturnData data = new JsonReturnData();

            if (ModelState.IsValid)
            {
                SubscriberRequestData request = subscriberFormData.ToRequestData();
                SubscriberResultData  result  =
                    await WebApiClient.PostFormJsonAsync <SubscriberRequestData, SubscriberResultData>(
                        Constant.WebApiControllerNewsletters, Constant.WebApiCreateSubscriber, request);

                if (result == null)
                {
                    data.ErrorMessage     = SharedResources.ServerError;
                    data.OperationSuccess = false;
                }
                else if (!result.OperationSuccess && result.Errors != null && result.Errors.Count > 0)
                {
                    data.ErrorMessage     = result.Errors.First();
                    data.OperationSuccess = false;
                }
                else if (result.OperationSuccess)
                {
                    data.SuccessMessage   = NewsletterResources.ResourceManager.GetString("Ok", Thread.CurrentThread.CurrentCulture);
                    data.OperationSuccess = true;
                }
                return(new OmsJsonResult(data));
            }
            data = new JsonReturnData
            {
                OperationSuccess = false,
                ErrorMessage     = SharedResources.ValidationErrors
            };
            return(new OmsJsonResult(data));
        }
Beispiel #2
0
        public async Task <OmsJsonResult> UpdateSubscriber(SubscriberFormData subscriberFormData)
        {
            SubscriberRequestData request = subscriberFormData.ToRequestData();
            SubscriberResultData  result  = await WebApiClient.PostFormJsonAsync <SubscriberRequestData, SubscriberResultData>(Constant.WebApiControllerNewsletters, Constant.WebApiUpdateSubscriber, request);

            JsonReturnData data = new JsonReturnData();

            if (result == null)
            {
                data.ErrorMessage     = SharedResources.ServerError;
                data.OperationSuccess = false;
            }
            else if (!result.OperationSuccess && result.Errors != null && result.Errors.Count > 0)
            {
                data.ErrorMessage     = result.Errors.First();
                data.OperationSuccess = false;
            }
            else if (result.OperationSuccess)
            {
                data.SuccessMessage   = UserResources.Ok;
                data.OperationSuccess = true;
            }
            return(new OmsJsonResult(data));
        }