public bool SaveTweet(TweetMessage tweetMsg)
        {
            bool IsSuccess = false;

            try
            {
                using (_dbContext = new FSEAssignmentEntities())
                {
                    var tweets = _dbContext.People.Where(x => x.User_Id.Trim().ToUpper() == tweetMsg.User_Id.Trim().ToUpper()).FirstOrDefault();
                    var tweet  = _dbContext.Tweets.Where(x => x.Tweet_Id == tweetMsg.Tweet_Id).FirstOrDefault();
                    if (tweet == null && tweetMsg.Tweet_Id == 0)
                    {
                        tweet         = new Tweet();
                        tweet.User_Id = tweetMsg.User_Id;
                        tweet.Message = tweetMsg.Message;
                        tweet.Created = DateTime.Now;

                        _dbContext.Entry(tweet).State = System.Data.Entity.EntityState.Added;
                    }
                    else
                    {
                        tweet.Message = tweetMsg.Message;
                    }
                    IsSuccess = true;

                    _dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }

            return(IsSuccess);
        }
        public bool RegisterOrUpdateUser(PersonModel personModel)
        {
            bool isRegistered = false;

            try
            {
                using (_dbContext = new FSEAssignmentEntities())
                {
                    Person person = _dbContext.People.Where(x => x.User_Id.ToUpper().Trim() == personModel.User_Id.ToUpper().Trim()).FirstOrDefault();

                    if (person == null)
                    {
                        Person user = new Person();
                        user.User_Id  = personModel.User_Id;
                        user.Password = personModel.Password;
                        user.FullName = personModel.FullName;
                        user.Email    = personModel.Email;
                        user.Joined   = DateTime.Now;
                        user.Active   = true;
                        _dbContext.People.Add(user);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(personModel.Password.Trim()))
                        {
                            person.Password = personModel.Password;
                        }
                        person.FullName = personModel.FullName;
                        person.Email    = personModel.Email;
                        _dbContext.Entry <Person>(person).State = System.Data.Entity.EntityState.Modified;
                    }

                    _dbContext.SaveChanges();
                    isRegistered = true;
                }
            }
            catch (Exception ex)
            {
                isRegistered = false;
            }

            return(isRegistered);
        }
        public string DeleteTweet(int tweetId)
        {
            string strUserName = string.Empty;

            try
            {
                using (_dbContext = new FSEAssignmentEntities())
                {
                    var tweet = _dbContext.Tweets.Where(x => x.Tweet_Id == tweetId).FirstOrDefault();//_context.TWEETs.Where(x => x.tweet_id == tweetMsg.TweetId).FirstOrDefault();
                    if (tweet != null && tweetId != 0)
                    {
                        strUserName = tweet.User_Id;
                        _dbContext.Tweets.Remove(tweet);
                    }
                    _dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
            return(strUserName);
        }
        public TweetMessage EditTweet(int tweetId)
        {
            TweetMessage _editTweet = new TweetMessage();

            try
            {
                using (_dbContext = new FSEAssignmentEntities())
                {
                    var tweet = _dbContext.Tweets.Where(x => x.Tweet_Id == tweetId).FirstOrDefault();//_context.TWEETs.Where(x => x.tweet_id == tweetMsg.TweetId).FirstOrDefault();
                    _editTweet.User_Id  = tweet.User_Id;
                    _editTweet.Message  = tweet.Message;
                    _editTweet.Tweet_Id = tweet.Tweet_Id;
                    _editTweet.Created  = DateTime.Now;
                    _dbContext.Entry(_editTweet).State = System.Data.Entity.EntityState.Modified;
                    _dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }

            return(_editTweet);
        }
 // POST api/<controller>
 public void Post([FromBody] POMASTER pomaster)
 {
     dbContext.POMASTERs.Add(pomaster);
     dbContext.SaveChanges();
 }
Ejemplo n.º 6
0
 // POST api/values
 public void Post([FromBody] SUPPLIER supplier)
 {
     dbContext.SUPPLIERs.Add(supplier);
     dbContext.SaveChanges();
 }
Ejemplo n.º 7
0
 // POST api/<controller>
 public void Post([FromBody] ITEM value)
 {
     dbContext.ITEMs.Add(value);
     dbContext.SaveChanges();
 }
 // POST api/<controller>
 public void Post([FromBody] PODETAIL poDetail)
 {
     dbContext.PODETAILs.Add(poDetail);
     dbContext.SaveChanges();
 }