Exemplo n.º 1
0
        public async Task <ContactAdsDTO> PostContactAds(ContactAdsDTO model)
        {
            var output = new ContactAdsDTO();

            output = model;
            var result = await _repoWrapper.Advertising.PostContactAds(model);

            if (result)
            {
                //Sent Email
                Utils.Util.SendMail("Quảng cáo Hanoma", "*****@*****.**", "Quảng cáo hanoma", "Đăng ký quảng cáo hanoma",
                                    $"{model.Name} - {model.Mobile} - {model.Address}  " + Environment.NewLine + $"{model.Content}", _repoWrapper.AspNetUsers.setting());
                output.ErrorCode = "00";
                output.Message   = "Yêu cầu quảng cáo của bạn đã gửi tới Hanoma, chúng tôi sẽ sớm liên hệ với bạn!";
            }
            else
            {
                output.ErrorCode = "01";
                output.Message   = "Có lỗi trong quá trình xử lý";
            }
            return(output);
        }
Exemplo n.º 2
0
        public async Task <ContactAdsDTO> ContactAdsDTO(ContactAdsDTO contactAds)
        {
            ContactAdsDTO output = new ContactAdsDTO();
            var           jwt    = JsonConvert.DeserializeObject <SumProfileResponseDTO>(_httpContextAccessor.HttpContext.Request.Cookies["JWT"]);

            if (jwt != null)
            {
                _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt.JWT);
                contactAds.UserId = jwt.UserId;
                string apiUrl        = $"/api/v1/Advertising/PostContactAds";
                var    json          = JsonConvert.SerializeObject(contactAds, Formatting.Indented);
                var    stringContent = new StringContent(json, Encoding.UTF8, "application/json");
                var    response      = await _client.PostAsync(apiUrl, stringContent);

                if (response.IsSuccessStatusCode)
                {
                    string responseStream = await response.Content.ReadAsStringAsync();

                    output = JsonConvert.DeserializeObject <ContactAdsDTO>(responseStream);
                }
            }
            return(output);
        }
Exemplo n.º 3
0
        public async Task <bool> PostContactAds(ContactAdsDTO model)
        {
            try
            {
                var modelContact = new ContactAds();
                modelContact.Name         = model.Name;
                modelContact.Address      = model.Address;
                modelContact.Content      = model.Content;
                modelContact.Mobile       = model.Mobile;
                modelContact.Email        = model.Email;
                modelContact.CreateDate   = DateTime.Now;
                modelContact.LastEditDate = DateTime.Now;
                modelContact.Status       = 1;

                HanomaContext.ContactAds.Add(modelContact);
                await HanomaContext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        public async Task <JsonResult> ContactAds(ContactAdsDTO contactAdsDTO)
        {
            var result = await _repoWrapper.Profile.ContactAdsDTO(contactAdsDTO);

            return(Json(result));
        }