protected void btnSubmit_Click(object sender, EventArgs e)
        {
            TenantComplaint objTenantComplaint = new TenantComplaint();

            objTenantComplaint.PropertyId  = propertyId;
            objTenantComplaint.CategoryId  = Convert.ToInt32(ddlCategories.SelectedValue);
            objTenantComplaint.Location    = txtLocation.Text;
            objTenantComplaint.Description = txtDescription.Text;
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(Configs.Global.BaseURL);
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var json = JsonConvert.SerializeObject(objTenantComplaint);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = client.PostAsync(Configs.Global.SaveTeantComplaint, data).Result;

            if (response.IsSuccessStatusCode)
            {
                Response.Redirect("TenantLogSuccess.html");
            }
            else
            {
                StatusInfo objStatus = JsonConvert.DeserializeObject <StatusInfo>(response.Content.ReadAsStringAsync().Result);
                lblMessage.Text     = objStatus.Message;
                lblMessage.CssClass = "label-error";
            }
        }
Esempio n. 2
0
        public int SaveTenantComplaint(TenantComplaint tenantComplaint)
        {
            int logId = 0;

            try
            {
                using (SqlConnection connection = new SqlConnection())
                {
                    connection.ConnectionString = ConfigurationManager.ConnectionStrings["BizBuildingDB"].ToString();
                    connection.Open();
                    SqlCommand cmd = new SqlCommand("uspSaveTenantComplaint", connection);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@PropertyId", tenantComplaint.PropertyId));
                    cmd.Parameters.Add(new SqlParameter("@CategoryId", tenantComplaint.CategoryId));
                    cmd.Parameters.Add(new SqlParameter("@Location", tenantComplaint.Location));
                    cmd.Parameters.Add(new SqlParameter("@GeoLocation", tenantComplaint.GeoLocation));
                    cmd.Parameters.Add(new SqlParameter("@Description", tenantComplaint.Description));
                    cmd.Parameters.Add(new SqlParameter("@Status", tenantComplaint.Status));
                    logId = (int)cmd.ExecuteScalar();
                    cmd.Dispose();
                    connection.Close();
                }
            }
            catch (Exception ex) { }
            return(logId);
        }
        public HttpResponseMessage SaveCompliant(TenantComplaint tenantComplaint)
        {
            int logId = _repository.SaveTenantComplaint(tenantComplaint);

            if (logId > 0)
            {
                StatusInfo objStatus = new StatusInfo();
                objStatus.Message = Resources.Messages.StatusSuccess;
                return(Request.CreateResponse(HttpStatusCode.OK, objStatus));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Resources.Messages.InvalidData));
            }
        }