コード例 #1
0
 partial void DeleteRoutetag(Routetag instance);
コード例 #2
0
 partial void UpdateRoutetag(Routetag instance);
コード例 #3
0
 partial void InsertRoutetag(Routetag instance);
コード例 #4
0
		private void detach_Routetags(Routetag entity)
		{
			this.SendPropertyChanging();
			entity.Route = null;
		}
コード例 #5
0
		private void attach_Routetags(Routetag entity)
		{
			this.SendPropertyChanging();
			entity.Route = this;
		}
コード例 #6
0
ファイル: RouteModel.cs プロジェクト: Youssouf/Cykelnet
        public static int insertRoute(RouteModel rm)
        {
            // Create route tuple (meta data)
            Route r = new Route();
            r.User_ID = rm.userID;
            r.City = rm.city;
            r.Name = rm.name;
            r.Heightmeters = rm.heightmeters;
            r.Description = rm.description;
            r.ValidFrom = DateTime.Now;
            _db.Routes.InsertOnSubmit(r);
            _db.SubmitChanges();

            // Create event, that route was created
            RouteCreatedEvent rce = new RouteCreatedEvent(r);
            rce.save();

            // Add tags
            List<Tag> insTags = TagModel.insertTags(rm.tags);
            if (insTags != null)
            {

                List<Routetag> rtags = new List<Routetag>();
                foreach (Tag t in insTags)
                {
                    Routetag rt = new Routetag();
                    rt.Route_ID = r.RouteID;
                    rt.Tag_ID = t.Tag_ID;
                    rtags.Add(rt);
                }
                _db.Routetags.InsertAllOnSubmit(rtags);
                _db.SubmitChanges();
            }

            // Update inputted routemodel with id given by DB
            rm.routeID = r.RouteID;

            // Select the SPROC to use
            SqlConnection conn = new SqlConnection(_db.Connection.ConnectionString);
            conn.Open();
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = "InsertRouteLineString";
            cmd.CommandType = CommandType.StoredProcedure;

            // Add arguments to the SPROC
            SqlParameter param = new SqlParameter("@LINESTRING", SqlDbType.Udt);
            param.SqlDbType = SqlDbType.Udt;
            param.UdtTypeName = "geography";
            param.Value = rm.routeLineString;

            cmd.Parameters.Add(param);

            cmd.Parameters.Add(new SqlParameter("@ROUTEID", r.RouteID));

            cmd.ExecuteNonQuery();

            return r.RouteID;
        }