Esempio n. 1
0
        public async Task <IActionResult> DeleteTodayMood(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ApplicationUser user = await userManager.GetUserAsync(User);

            UserMood todaymood = await db.UserMoods.Where(m => m.UserMoodId == id).SingleOrDefaultAsync();

            if (todaymood == null)
            {
                return(NotFound());
            }

            db.UserMoods.Remove(todaymood);

            db.Notifications.Add(new Notification()
            {
                Name       = "Удалено настроение за день",
                DateCreate = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now),
                UserId     = user.Id
            });

            await db.SaveChangesAsync();

            return(RedirectToAction("GameRoom", "Home"));
        }
Esempio n. 2
0
 private void LoadExtensions()
 {
     this.version                = this.im.LoadExtension <SoftwareVersion>();
     this.sdisco                 = this.im.LoadExtension <ServiceDiscovery>();
     this.ecapa                  = this.im.LoadExtension <EntityCapabilities>();
     this.ping                   = this.im.LoadExtension <S22.Xmpp.Extensions.Ping>();
     this.attention              = this.im.LoadExtension <Attention>();
     this.time                   = this.im.LoadExtension <EntityTime>();
     this.block                  = this.im.LoadExtension <BlockingCommand>();
     this.pep                    = this.im.LoadExtension <Pep>();
     this.userTune               = this.im.LoadExtension <UserTune>();
     this.userAvatar             = this.im.LoadExtension <UserAvatar>();
     this.userMood               = this.im.LoadExtension <UserMood>();
     this.dataForms              = this.im.LoadExtension <DataForms>();
     this.featureNegotiation     = this.im.LoadExtension <FeatureNegotiation>();
     this.streamInitiation       = this.im.LoadExtension <StreamInitiation>();
     this.siFileTransfer         = this.im.LoadExtension <SIFileTransfer>();
     this.inBandBytestreams      = this.im.LoadExtension <InBandBytestreams>();
     this.userActivity           = this.im.LoadExtension <UserActivity>();
     this.socks5Bytestreams      = this.im.LoadExtension <Socks5Bytestreams>();
     this.FileTransferSettings   = new S22.Xmpp.Client.FileTransferSettings(this.socks5Bytestreams, this.siFileTransfer);
     this.serverIpCheck          = this.im.LoadExtension <ServerIpCheck>();
     this.inBandRegistration     = this.im.LoadExtension <InBandRegistration>();
     this.chatStateNotifications = this.im.LoadExtension <ChatStateNotifications>();
     this.bitsOfBinary           = this.im.LoadExtension <BitsOfBinary>();
 }
        // PUT api/MUserMood/5
        public async Task <IHttpActionResult> PutUserMood(long id, UserMood userMood)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != userMood.Id)
            {
                return(BadRequest());
            }

            try
            {
                await _userMoodService.UpdateUserMood(userMood);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserMoodExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 4
0
        public async Task <long> CreateUserMood(UserMood userMood)
        {
            userMood = _userMoodRepository.Create(userMood);
            await _unit.Commit();

            await _feedEventService.GenerateFeedEvent(userMood);

            await _unit.Commit();

            return(userMood.Id);
        }
        public async Task <IHttpActionResult> PostUserMood(UserMood userMood)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            userMood.Id = await _userMoodService.CreateUserMood(userMood);

            return(CreatedAtRoute("DefaultApi", new { id = userMood.Id }, userMood));
        }
        public async Task <IHttpActionResult> GetUserMood(long id)
        {
            UserMood userMood = await _userMoodService.FindUserMood(id);

            if (userMood == null)
            {
                return(NotFound());
            }

            return(Ok(userMood));
        }
Esempio n. 7
0
        public MainWindow(User user, LoginView lgview)
        {
            InitializeComponent();
            LoginViewWindow             = lgview;
            this.DataContext            = MainWDVM = new MainWindowViewModel(user);
            this.lbUserName.DataContext = MainWDVM.MainUser;

            // Hiện tâm trạng người dùng
            using (var db = new MyContext())
            {
                string mainUser = user.UserID;
                int    day      = DateTime.Today.Day;
                int    month    = DateTime.Today.Month;
                int    year     = DateTime.Today.Year;


                var emptyDate = db.UserMoods.Where(u => u.UserID == mainUser &&
                                                   u.Date.Day == day &&
                                                   u.Date.Month == month &&
                                                   u.Date.Year == year).SingleOrDefault() == null;
                // Kiểm tra có mood trùng ngày hôm nay không
                // Nếu đã có rồi
                if (emptyDate != true)
                {
                    //MessageBox.Show("Not null");
                    var userEmo = (from n in db.UserMoods
                                   where n.UserID == mainUser &&
                                   n.Date.Day == day &&
                                   n.Date.Month == month &&
                                   n.Date.Year == year
                                   select n).First();
                    if (userEmo != null)
                    {
                        lbEmotion.Content     = db.Moods.Find(userEmo.MoodID).Name;
                        imgEmotionIcon.Source = ChangeEmoImg(userEmo.MoodID);
                    }
                }
                // Nếu chưa có
                else
                {
                    UserMood userMood = new UserMood
                    {
                        UserID = mainUser,
                        Date   = DateTime.Today,
                        MoodID = 1
                    };
                    db.UserMoods.Add(userMood);
                    db.SaveChanges();
                    lbEmotion.Content     = db.Moods.Find(userMood.MoodID).Name;
                    imgEmotionIcon.Source = ChangeEmoImg(userMood.MoodID);
                }
            }
        }
Esempio n. 8
0
        public IActionResult Submit(int MoodId)
        {
            Mood     newMood  = _context.Moods.Single(s => s.Id == MoodId);
            UserMood userMood = new UserMood
            {
                UserId = _userManager.GetUserId(User),
                Mood   = newMood
            };

            _context.UserMoods.Add(userMood);
            _context.SaveChanges();

            return(Redirect("/Food"));
        }
Esempio n. 9
0
 public async Task UpdateUserMood(UserMood userMood)
 {
     _userMoodRepository.Update(userMood);
     await _unit.Commit();
 }