Exemple #1
0
 public static void DeletePerson(string id)
 {
     using (var ctx = new EFMVCContext())
     {
         var person = ctx.People.FirstOrDefault(a => a.user_id == id);
         person.active           = false;
         ctx.Entry(person).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemple #2
0
 public static PersonModel Profile(PersonModel personModel)
 {
     using (var ctx = new EFMVCContext())
     {
         var person = ctx.People.FirstOrDefault(a => a.user_id == personModel.UserId);
         person.password = CreateMD5(personModel.Password);
         person.fullName = personModel.FullName;
         person.email    = personModel.Email;
         ctx.People.Add(person);
         ctx.Entry(person).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
         return(person.GetPersonModel());
     }
 }
Exemple #3
0
 public static TweetModel AddTweet(TweetModel model)
 {
     using (var ctx = new EFMVCContext())
     {
         if (model.TweetId == 0)
         {
             model.Created = DateTime.Now;
             var tweet = model.GetTweet();
             ctx.Tweets.Add(tweet);
             ctx.SaveChanges();
             return(tweet.GetTweetModel());
         }
         else
         {
             var tweet = ctx.Tweets.FirstOrDefault(a => a.tweet_id == model.TweetId);
             tweet.message          = model.Message;
             ctx.Entry(tweet).State = System.Data.Entity.EntityState.Modified;
             ctx.SaveChanges();
             return(tweet.GetTweetModel());
         }
     }
 }