示例#1
0
        public ActionResult CheckMeIn(CheckInViewModel form)
        {
            if (ModelState.IsValid)
            {
                CheckIn checkIn = new CheckIn();
                checkIn.Text            = form.Text;
                checkIn.Latitude        = form.Latitude;
                checkIn.Longitude       = form.Longitude;
                checkIn.Timezone        = (decimal)Session[Functions.Settings.Session.TIMEZONE];
                checkIn.CreatedDateTime = DateTime.Now;
                checkIn.IsDeleted       = false;
                checkIn.UserID          = User.Identity.GetUserId();

                using (StormChaseCheckInEntities db = new StormChaseCheckInEntities())
                {
                    db.Database.Connection.Open();

                    db.CheckIns.Add(checkIn);
                    db.SaveChanges();
                }

                return(RedirectToAction("MyCheckIns", "Home"));
            }

            return(View(form));
        }
示例#2
0
        public ActionResult Settings(SettingsViewModel form)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Settings", "Home"));
            }

            using (StormChaseCheckInEntities db = new StormChaseCheckInEntities())
            {
                Setting setting = new Setting();
                setting = db.Settings.Where(x => x.SettingsTypeID == (int)Enums.SettingsType.Timezone).FirstOrDefault();

                if (setting != null)
                {
                    setting.SettingsValue = decimal.Parse(form.SelectedTimezone);

                    db.SaveChanges();
                    Session[Functions.Settings.Session.TIMEZONE] = setting.SettingsValue;

                    return(RedirectToAction("CheckMeIn", "Home"));
                }

                return(RedirectToAction("Settings", "Home"));
            }
        }
示例#3
0
        public ActionResult MyCheckIns()
        {
            using (StormChaseCheckInEntities db = new StormChaseCheckInEntities())
            {
                List <CheckInListViewModel> model = new List <CheckInListViewModel>();
                model = (from x in db.CheckIns
                         where !x.IsDeleted
                         orderby x.CreatedDateTime descending
                         select new CheckInListViewModel
                {
                    CheckInID = x.CheckInID,
                    Text = x.Text,
                    Latitude = x.Latitude,
                    Longitude = x.Longitude,
                    Timezone = x.Timezone,
                    CreatedDate = x.CreatedDateTime
                }).ToList();

                return(View(model));
            }
        }
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                //return RedirectToLocal(returnUrl);
                using (StormChaseCheckInEntities db = new StormChaseCheckInEntities())
                {
                    Setting timezone = new Setting();
                    timezone = db.Settings.Where(x => x.SettingsTypeID == (int)Enums.SettingsType.Timezone).SingleOrDefault();

                    if (timezone != null)
                    {
                        Session[Settings.Session.TIMEZONE] = timezone.SettingsValue;

                        return(RedirectToAction("CheckMeIn", "Home"));
                    }
                }

                return(View(model));

            //case SignInStatus.LockedOut:
            //    return View("Lockout");
            //case SignInStatus.RequiresVerification:
            //    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
示例#5
0
        public ActionResult Settings()
        {
            using (StormChaseCheckInEntities db = new StormChaseCheckInEntities())
            {
                SettingsViewModel     model        = new SettingsViewModel();
                List <SelectListItem> timezoneList = new List <SelectListItem>();

                for (int hour = -12; hour < 12; hour++)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text  = hour.ToString() + " hours";
                    item.Value = hour.ToString();

                    timezoneList.Add(item);
                }

                model.Timezone = timezoneList;
                //model.SelectedTimezone = db.Settings.Where(x => x.SettingsTypeID == (int)Enums.SettingsType.Timezone).Select(s => s.SettingsValue.ToString()).FirstOrDefault();

                return(View(model));
            }
        }