public async Task <IActionResult> Update([FromRoute] Int32 id, [FromBody] CreateContactUsRequest createContact)
        {
            var contactUs = new ContactUs
            {
                Id      = id,
                Email   = createContact.Email,
                Phone   = createContact.Phone,
                WebSite = createContact.WebSite,
                Address = createContact.Address
            };

            var status = await _contactUsService.UpdateContactUsAsync(contactUs);



            if (status == 1)
            {
                return(Ok(contactUs));
            }
            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }
Beispiel #2
0
        public async Task <ContactUsResponse> Post(CreateContactUsRequest request)
        {
            var proxyIp  = HttpContext.Request.Headers["X-Real-IP"].ToString();
            var senderIp = string.IsNullOrEmpty(proxyIp) ?
                           HttpContext.Connection.RemoteIpAddress.ToString()
                :
                           proxyIp;
            var createdModel = new Models.ContactUsMessage
            {
                Name     = request.Name,
                Email    = request.Email,
                Message  = request.Message,
                SendTime = DateTime.UtcNow,
                SenderIp = senderIp
            };

            landingDbContext.ContactUsMessages.Add(createdModel);
            await landingDbContext.SaveChangesAsync();

            return(new ContactUsResponse
            {
                Name = createdModel.Name,
                Email = createdModel.Email,
                Message = createdModel.Message
            });
        }
        public async Task <IActionResult> Create([FromBody] CreateContactUsRequest createContact)
        {
            var contactUs = new ContactUs
            {
                Email   = createContact.Email,
                Phone   = createContact.Phone,
                WebSite = createContact.WebSite,
                Address = createContact.Address
            };

            var status = await _contactUsService.CreateContactUsAsync(contactUs);

            if (status == 1)
            {
                var response = new CategoryResponse {
                    Id = contactUs.Id
                };
                return(Ok(response));
            }
            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }