예제 #1
0
        public ActionResult Create(AddressCreationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                TipstaffRecord tr         = db.TipstaffRecord.Find(model.tipstaffRecordID);
                string         controller = genericFunctions.TypeOfTipstaffRecord(tr);
                //do stuff
                tr.addresses.Add(model.address);
                db.SaveChanges();
                if (Request.IsAjaxRequest())
                {
                    string url = string.Format("window.location='{0}';", Url.Action("Details", controller, new { id = model.tipstaffRecordID }));
                    return(JavaScript(url));
                }
                else
                {
                    return(RedirectToAction("Details", controller, new { id = model.tipstaffRecordID }));
                }
            }

            catch (Exception ex)
            {
                _logger.LogError(ex, $"Exception in AddressController in Create method, for user {((CPrincipal)User).UserID}");
                ErrorModel errModel = new ErrorModel(2);
                errModel.ErrorMessage  = genericFunctions.GetLowestError(ex);
                TempData["ErrorModel"] = errModel;
                return(RedirectToAction("IndexByModel", "Error", errModel ?? null));
            }
        }
예제 #2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                AddressCreationModel addressCreator = new AddressCreationModel(db);
                int addressID = addressCreator.GetAddressID(model._StreetAddress1, model._StreetAddress2, model._CityID, model._StateID, model._ZipcodeID);

                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, _FirstName = model._FirstName, _LastName = model._LastName, _PickupDay_ID = model._dayID, _Address_ID = addressID, PhoneNumber = model.Number, role = 0
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            model.days   = new SelectList(db.WeekDay, "_ID", "_Day");
            model.states = new SelectList(db.State, "_ID", "_State");
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #3
0
        public ActionResult Create(int id)
        {
            AddressCreationModel model = new AddressCreationModel(id);

            if (model.tipstaffRecord.caseStatus.sequence > 3)
            {
                TempData["UID"] = model.tipstaffRecord.UniqueRecordID;
                return(RedirectToAction("ClosedFile", "Error"));
            }
            return(View(model));
        }
예제 #4
0
        // GET: ShipAddresses/Create
        public async Task <IActionResult> Create()
        {
            AddressCreationModel acm = new AddressCreationModel();

            acm.Provinces        = new List <SelectListItem>();
            acm.Cities           = new List <SelectListItem>();
            acm.ProvinceListName = "Province";
            List <Province> pList = await _addressRepository.GetProvincesAsync();

            foreach (Province p in pList)
            {
                acm.Provinces.Add(new SelectListItem {
                    Text = p.ProvinceName, Value = p.ProvinceID.ToString()
                });
            }
            acm.CityListName = "City";
            return(View(acm));
        }