Beispiel #1
0
        public HttpResponseMessage AddContactUs(AddContactUsRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemResponse <int> response = new ItemResponse <int>();

            response.Item = ContactUsService.UpdateContactUs(model);
            return(Request.CreateResponse(response));
        }
Beispiel #2
0
        public IHttpActionResult AddContactUs(AddContactUsRequest addContactUsRequest)
        {
            var responses = new Responses();

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var contactUs = new ContactUs()
                {
                    Name      = addContactUsRequest.Name,
                    Email     = addContactUsRequest.Email,
                    Mobile    = addContactUsRequest.Mobile,
                    Comment   = addContactUsRequest.Comment,
                    CreatedBy = Utility.UserId
                };
                int result = iContactUs.AddContactUs(contactUs);
                if (result > 0)
                {
                    responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                    responses.Description = "ContactUs added successfully.";
                }
                else if (result == -2)
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "ContactUs alread exists.";
                }
                else
                {
                    responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                    responses.Description = "Error while adding contactus.";
                }
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while adding contactus.";

                Utility.WriteLog("AddContactUs", addContactUsRequest, "Error while adding contactus. (ContactUsguestController)", ex.ToString());
            }
            return(Ok(responses));
        }