Exemplo n.º 1
0
 public IActionResult updateRoute([FromBody] createRoute updateRoute)
 {
     try
     {
         if (updateRoute.routeId <= 0)
         {
             return(StatusCode((int)HttpStatusCode.BadRequest, new { ErrorMessage = "Please enter routeId" }));
         }
         DataTable dt       = Data.Route.updateRoute(updateRoute);
         string    Response = dt.Rows[0][0].ToString();
         if (Response == "Success")
         {
             return(StatusCode((int)HttpStatusCode.OK, "Updated Successfully"));
         }
         else
         {
             return(StatusCode((int)HttpStatusCode.Forbidden, new { ErrorMessage = Response }));
         }
     }
     catch (Exception e)
     {
         string SaveErrorLog = Data.Common.SaveErrorLog("updateRoute", e.Message);
         return(StatusCode((int)HttpStatusCode.InternalServerError, new { ErrorMessage = e.Message }));
     }
 }
Exemplo n.º 2
0
        public IActionResult createRoute(createRoute createRoute)
        {
            try
            {
                if (createRoute.routeName == "" || createRoute.routeName == null)
                {
                    return(StatusCode((int)HttpStatusCode.BadRequest, new { ErrorMessage = "Please enter routeName" }));
                }
                else if (createRoute.designatedCharityId < 0 || createRoute.designatedCharityId == null)
                {
                    return(StatusCode((int)HttpStatusCode.BadRequest, new { ErrorMessage = "Please enter userId" }));
                }

                DataSet ds       = Data.Route.createRoute(createRoute);
                string  Response = ds.Tables[0].Rows[0]["SuccessMessage"].ToString();

                if (Response == "Success")
                {
                    string routeId = ds.Tables[1].Rows[0]["routeId"].ToString();
                    return(StatusCode((int)HttpStatusCode.OK, new { routeId, message = "Route Created successfully" }));
                }
                else
                {
                    return(StatusCode((int)HttpStatusCode.Forbidden, new { ErrorMessage = Response }));
                }
            }
            catch (Exception e)
            {
                string SaveErrorLog = Data.Common.SaveErrorLog("createRoute", e.Message);
                return(StatusCode((int)HttpStatusCode.InternalServerError, new { ErrorMessage = e.Message }));
            }
        }
Exemplo n.º 3
0
        public static DataSet createRoute([FromBody] createRoute createRoute)
        {
            try
            {
                string ConnectionString = Common.GetConnectionString();

                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(new SqlParameter("@routeName", createRoute.routeName));
                parameters.Add(new SqlParameter("@comments", createRoute.comments));
                parameters.Add(new SqlParameter("@userId", createRoute.designatedCharityId));
                parameters.Add(new SqlParameter("@isPrivate", createRoute.isPrivate));

                using (DataSet ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, "spcreateRoute", parameters.ToArray()))
                {
                    return(ds);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        public static DataTable updateRoute([FromBody] createRoute updateRoute)
        {
            try
            {
                string ConnectionString        = Common.GetConnectionString();
                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(new SqlParameter("@routeId", updateRoute.routeId));
                parameters.Add(new SqlParameter("@routeName", updateRoute.routeName));
                parameters.Add(new SqlParameter("@comments", updateRoute.comments));
                parameters.Add(new SqlParameter("@designatedCharityId", updateRoute.designatedCharityId));
                parameters.Add(new SqlParameter("@startingPoint", updateRoute.startingPoint));
                parameters.Add(new SqlParameter("@endPoint", updateRoute.endPoint));
                parameters.Add(new SqlParameter("@isPrivate", updateRoute.isPrivate));

                using (DataTable dt = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, "spupdateRoute", parameters.ToArray()).Tables[0])
                {
                    return(dt);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }