public HttpResponseMessage SaveComment(tbCommentaryModelPost id)
        {
            int result = 0;

            try
            {
                tbCommentary c = new tbCommentary();
                c.HerID         = id.HerID;
                c.Audited       = 0;
                c.PostTime      = DateTime.Now;
                c.InforPlatform = id.InforPlatform;
                c.UserLocation  = System.Data.Entity.Spatial.DbGeography.PointFromText($"Point({id.Longitude} {id.Latitude})", System.Data.Entity.Spatial.DbGeography.DefaultCoordinateSystemId);

                c.UserName  = id.UserName;
                c.Commented = 1;
                c.Contents  = id.Contents;
                dbContext.tbCommentaries.Add(c);
                dbContext.SaveChanges();
                result = 1;
            }
            catch (Exception e)
            {
                result = 0;
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Beispiel #2
0
 public IHttpActionResult UpdateLang(LanguageModel par)
 {
     try
     {
         tbLanguage p = new tbLanguage();
         p.Langcode  = par.Langcode;
         p.LangName  = par.LangName;
         p.IsDefault = par.IsDefault;
         dbContext.tbLanguages.Add(p);
         dbContext.SaveChanges();
         return(Ok(1));
     }
     catch
     {
         return(Ok(1));
     }
 }
Beispiel #3
0
        public HttpResponseMessage Viewed(ViewedPost id)
        {
            int      result = 0;
            tbViewed c      = new tbViewed();

            c.HerID         = id.HerID;
            c.InforPlatform = id.InforPlatform;
            c.TimeViewed    = DateTime.Now;
            c.UserLocation  = System.Data.Entity.Spatial.DbGeography.PointFromText(id.UserLocation, System.Data.Entity.Spatial.DbGeography.DefaultCoordinateSystemId);
            c.UserName      = id.UserName;
            c.Viewed        = 1;
            dbContext.tbVieweds.Add(c);
            dbContext.SaveChanges();
            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Beispiel #4
0
 public IHttpActionResult DeleteHeritagerInfo(int id)
 {
     try
     {
         var student = dbContext.tbHeritagerInfors.Where(x => x.ID == id).FirstOrDefault();
         dbContext.tbHeritagerInfors.Attach(student);
         dbContext.tbHeritagerInfors.Remove(student);
         dbContext.SaveChanges();
         return(Ok(1));
     }
     catch
     {
         return(Ok(0));
     }
 }
Beispiel #5
0
 public IHttpActionResult Liked(LikedPost id)
 {
     try
     {
         tbLiked c = new tbLiked();
         c.HerID         = id.HerID;
         c.InforPlatform = id.InforPlatform;
         c.LikedTime     = DateTime.Now;
         c.UserLocation  = System.Data.Entity.Spatial.DbGeography.PointFromText($"Point({id.Longitude} {id.Latitude})", System.Data.Entity.Spatial.DbGeography.DefaultCoordinateSystemId);
         c.UserName      = id.UserName;
         c.Liked         = 1;
         dbContext.tbLikeds.Add(c);
         dbContext.SaveChanges();
         return(Ok(1));
     }
     catch
     {
         return(Ok(0));
     }
 }
Beispiel #6
0
 public IHttpActionResult UpdateTag(TagModel par)
 {
     try
     {
         if (!dbContext.tbTags.Where(x => x.TagName == par.TagName).Any())
         {
             tbTag p = new tbTag();
             p.TagIDParent    = par.TagIDParent;
             p.TagName        = par.TagName;
             p.TagDescription = par.TagDescription;
             dbContext.tbTags.Add(p);
             dbContext.SaveChanges();
             return(Ok(1));
         }
         return(Ok(0));
     }
     catch
     {
         return(BadRequest());
     }
 }