示例#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));
        }
示例#2
0
        /// <summary>
        /// Return the view to add subscriber.
        /// </summary>
        /// <returns>adding view</returns>
        public ActionResult GetCreateSubscriber()
        {
            SubscriberFormData subscriberFormData = new SubscriberFormData();

            ViewBag.Action = "CreateSubscriber";
            return(PartialView("Partials/_ManageSubscriber", subscriberFormData));
        }
示例#3
0
 /// <summary>
 /// From FORMDATA To REQUESTDATA
 /// </summary>
 /// <param name="subscriberFormData"></param>
 /// <returns></returns>
 public static SubscriberRequestData ToRequestData(this SubscriberFormData subscriberFormData)
 {
     if (subscriberFormData == null)
     {
         return(new SubscriberRequestData());
     }
     return(new SubscriberRequestData
     {
         SubscriberDto = subscriberFormData.ToItemData()
     });
 }
示例#4
0
        /// <summary>
        /// FROM ITEM DATA TO FORM DATA.
        /// </summary>
        /// <param name="resultData">the itemData to convert</param>
        /// <returns>the formdata result</returns>
        public static SubscriberFormData ToFormData(this SubscriberResultData resultData)
        {
            if (resultData == null)
            {
                return(new SubscriberFormData());
            }

            SubscriberFormData formData = new SubscriberFormData
            {
                SubscriberEmail     = resultData.SubscriberDto.SubscriberEmail,
                SubscriberLastName  = resultData.SubscriberDto.SubscriberLastName,
                SubscriberFirstName = resultData.SubscriberDto.SubscriberFirstName,
            };

            return(formData);
        }
示例#5
0
        /// <summary>
        /// FROM ITEM DATA TO FORM DATA.
        /// </summary>
        /// <param name="itemData">the itemData to convert</param>
        /// <returns>the formdata result</returns>
        public static SubscriberFormData ToFormData(this SubscriberItemData itemData)
        {
            if (itemData == null)
            {
                return(new SubscriberFormData());
            }

            SubscriberFormData formData = new SubscriberFormData
            {
                SubscriberEmail     = itemData.SubscriberEmail,
                SubscriberLastName  = itemData.SubscriberLastName,
                SubscriberFirstName = itemData.SubscriberFirstName,
            };

            return(formData);
        }
示例#6
0
        /// <summary>
        /// The update subscriber view.
        /// </summary>
        /// <param name="subscriberId">the subscriber id to update.</param>
        /// <returns>updating view</returns>
        public async Task <ActionResult> GetUpdateSubscriber(int subscriberId)
        {
            SubscriberFormData    subscriberFormData = new SubscriberFormData();
            SubscriberRequestData findRequest        = new SubscriberRequestData
            {
                SubscriberDto = new SubscriberItemData
                {
                    SubscriberId = subscriberId
                },
                FindSubscriberDto = FindSubscriberItemData.SubscriberId
            };

            SubscriberResultData result = await WebApiClient.PostFormJsonAsync <SubscriberRequestData, SubscriberResultData>(Constant.WebApiControllerNewsletters, Constant.WebApiFindSubscribers, findRequest);

            if (result != null && result.OperationSuccess && result.SubscriberDto != null)
            {
                subscriberFormData = result.ToFormData();
            }
            ViewBag.Action = "UpdateSubscriber";
            return(PartialView("Partials/_ManageSubscriber", subscriberFormData));
        }
示例#7
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));
        }