示例#1
0
        public async Task <ResultModel <AdminMailModel> > GetItem(AdminMailModel adminMailModel)
        {
            try
            {
                var listaAdminsMail = await GetList();

                foreach (var adminMail in listaAdminsMail.Data)
                {
                    if (!string.IsNullOrEmpty(adminMailModel.EmailID))
                    {
                        if (adminMail.EmailID.ToUpper().Equals(adminMailModel.EmailID.ToUpper()))
                        {
                            return(new SuccessResultModel <AdminMailModel>(adminMail));
                        }
                    }

                    if (adminMail.EmailAddress.ToUpper().Equals(adminMailModel.EmailAddress.ToUpper()))
                    {
                        return(new SuccessResultModel <AdminMailModel>(adminMail));
                    }
                }

                return(new ErrorResultModel <AdminMailModel>("No se encontró mail registrado"));
            }
            catch (Exception e)
            {
                return(new ErrorResultModel <AdminMailModel>(e.Message));
            }
        }
 public SenderRequestModel()
 {
     From                = new AdminMailModel();
     ReplyTo             = new AdminMailModel();
     MailListWithMembers = new MailListWithMembersModel();
     Campaign            = new CampaingWithContentRequestModel();
 }
 public SenderResponseModel()
 {
     From                = new AdminMailModel();
     ReplyTo             = new AdminMailModel();
     MailList            = new CreateMailListModel();
     Members             = new List <MemberModel>();
     CampaignWithContent = new CampaignWithContentResponseModel();
     CampaignSended      = false;
     Errors              = new List <string>();
 }
        public async Task <ActionResult <AdminMailModel> > Get([FromBody] AdminMailModel model)
        {
            var operationResult = await _module.GetItem(model);

            if (operationResult.Result != OperationResult.Ok)
            {
                return(BadRequest(operationResult));
            }

            return(Ok(operationResult));
        }
示例#5
0
        public async Task <ResultModel <AdminMailModel> > CreateAndEdit(AdminMailModel adminMailModel)
        {
            var action = "edit";

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    var parameters = new List <KeyValuePair <string, string> >();

                    if (!string.IsNullOrEmpty(adminMailModel.EmailID))
                    {
                        parameters.Add(new KeyValuePair <string, string>("EmailID", adminMailModel.EmailID));
                    }

                    if (!string.IsNullOrEmpty(adminMailModel.Name))
                    {
                        parameters.Add(new KeyValuePair <string, string>("Name", adminMailModel.Name));
                    }

                    if (!string.IsNullOrEmpty(adminMailModel.Name))
                    {
                        parameters.Add(new KeyValuePair <string, string>("EmailAddress", adminMailModel.EmailAddress));
                    }

                    var formContent = new FormUrlEncodedContent(parameters);

                    var url = String.Format("{0}/{1}/{2}?{3}&{4}", _baseUri.GetURI(), _modulo, action,
                                            _baseUri.GetAPIKEY(), _baseUri.GetFormat());

                    HttpResponseMessage response =
                        await client.PostAsync(url, formContent);

                    response.EnsureSuccessStatusCode();

                    string json = await response.Content.ReadAsStringAsync();

                    JObject rss = JObject.Parse(json);

                    try
                    {
                        JToken item = rss["root"]["ajaxResponse"]["email"];


                        AdminMailModel campaingCreatedModel = new AdminMailModel();
                        campaingCreatedModel = item.ToObject <AdminMailModel>();

                        return(new SuccessResultModel <AdminMailModel>(campaingCreatedModel));
                    }
                    catch
                    {
                        JToken item = rss["root"]["ajaxResponse"]["errors"];
                        return(new ErrorResultModel <AdminMailModel>(item.ToString()));
                    }
                }
            }
            catch (Exception e)
            {
                return(new ErrorResultModel <AdminMailModel>(e.Message));
            }
        }