public async Task <EventStoreResult> PushEventAsync(EventCreation body, CancellationToken cancellationToken = default) { var response = await GetEventsUrl() .PostJsonAsync(body, cancellationToken) .ConfigureAwait(false); string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); return(response.IsSuccessStatusCode ? JsonConvert.DeserializeObject <EventStoreResult>(content) : throw new InvalidOperationException(content)); }
public ActionResult CreateEvent(EventCreation eventcreation) { try { DbConnection dbHandle = new DbConnection(); if (Session["userid"] != null && Session["companyid"] != null) { dbHandle.Connection(); using (SqlCommand createevent = new SqlCommand("USPEventCreation", dbHandle.con)) { DateTime startdate = Convert.ToDateTime(eventcreation.startDate); DateTime enddate = Convert.ToDateTime(eventcreation.endDate); createevent.CommandType = CommandType.StoredProcedure; createevent.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToInt32(Session["userid"]); createevent.Parameters.Add("@EventName", SqlDbType.VarChar).Value = eventcreation.eventName; createevent.Parameters.Add("@EventStatusId", SqlDbType.Int).Value = 1; createevent.Parameters.Add("@EventDescription", SqlDbType.VarChar).Value = eventcreation.details; createevent.Parameters.Add("@StartDate", SqlDbType.Date).Value = startdate; createevent.Parameters.Add("@EndDate", SqlDbType.Date).Value = enddate; createevent.Parameters.Add("@Location", SqlDbType.VarChar).Value = eventcreation.where; createevent.Parameters.Add("@Time", SqlDbType.VarChar).Value = eventcreation.time; createevent.Parameters.Add("@CreatedBy", SqlDbType.Int).Value = Convert.ToInt32(Session["userid"]); createevent.Parameters.Add("@ModifyBy", SqlDbType.Int).Value = Convert.ToInt32(Session["userid"]); createevent.Parameters.Add("@CompanyId", SqlDbType.Int).Value = Convert.ToInt32(Session["companyid"]); dbHandle.con.Open(); createevent.ExecuteNonQuery(); dbHandle.con.Close(); } ViewBag.Message = "Event Created"; return(View(eventcreation)); } else { return(RedirectToAction("CreatePost", "CreatePost")); } } catch (Exception e) { ExceptionLog.Log(e, Request.UserHostAddress); // return RedirectToAction("CreatePost", "CreatePost"); return(RedirectToAction("Error_View", "CompanyRegister")); } finally { Dispose(); } }