コード例 #1
0
        public bool InsertInsurance(Insurance insurance)
        {
            bool result;

            _context.Add(insurance);
            _context.SaveChanges();
            result = true;

            return(result);
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,EMBG,BirthDate")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("Id,BussinessName,BussinessAddress,BussinessPhoneNumber")] MGA mGA)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mGA);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mGA));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Address,PhoneNumber,HealthStatus")] Advisor advisor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(advisor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(advisor));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Id,AgentNumber,FirstName,LastName,PolicyCount,BirthDate,HireDate,ProfilePicture")] Agent agent)
        {
            if (ModelState.IsValid)
            {
                _context.Add(agent);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(agent));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Id,Name,Surname,BirthDate,Passport,PhoneNum,Email")] Clients clients)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clients);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clients));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("Id,Category")] Categories categories)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categories);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categories));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,CaseNumber,Description,AccidentDate,UserId")] Case @case)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@case);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.User, "Id", "FirstName", @case.UserId);
            return(View(@case));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("Id,Chassis,Registration,Power,Volume,Premium,VehicleColor,AgreeDate,PolicyId")] CascoPolicy cascoPolicy)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cascoPolicy);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PolicyId"] = new SelectList(_context.Policy, "Id", "PolicyNumber", cascoPolicy.PolicyId);
            return(View(cascoPolicy));
        }
コード例 #10
0
        public async Task <IActionResult> Create([Bind("Id,PolicyNumber,PolicyType,OwnerId,AgentId")] Policy policy)
        {
            if (ModelState.IsValid)
            {
                _context.Add(policy);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AgentId"] = new SelectList(_context.Agent, "Id", "AgentNumber", policy.AgentId);
            ViewData["OwnerId"] = new SelectList(_context.User, "Id", "EMBG", policy.OwnerId);
            return(View(policy));
        }
コード例 #11
0
        public async Task <IActionResult> Create(int categoryId, [Bind("Id,Type,CategoryId,Info")] Types types)
        {
            types.CategoryId = categoryId;
            if (ModelState.IsValid)
            {
                _context.Add(types);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Types", new { id = categoryId, category = _context.Categories.Where(c => c.Id == categoryId).FirstOrDefault().Category }));
            }

            return(RedirectToAction("Index", "Types", new { id = categoryId, category = _context.Categories.Where(c => c.Id == categoryId).FirstOrDefault().Category }));
        }
コード例 #12
0
        public async Task <IActionResult> Create([Bind("Id,TypeHealth,Premium,AgreeDate,InsuredId,PolicyId")] HealthPolicy healthPolicy)
        {
            if (ModelState.IsValid)
            {
                _context.Add(healthPolicy);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InsuredId"] = new SelectList(_context.User, "Id", "EMBG", healthPolicy.InsuredId);
            ViewData["PolicyId"]  = new SelectList(_context.Policy, "Id", "PolicyNumber", healthPolicy.PolicyId);
            return(View(healthPolicy));
        }
コード例 #13
0
        public async Task <IActionResult> Create(string brokerName, int categoryId, [Bind("Id,BrokerId,CategoryId")] BrokersCategories brokersCategories)
        {
            /* var brokersName = brokerName; //brokersCategories.Broker.Name;
             * var broker = await _context.Brokers.FindAsync(brokersName);
             * brokersCategories.BrokerId = broker.Id;*/

            _context.Add(brokersCategories);

            await _context.SaveChangesAsync();



            return(RedirectToAction("Index", "BrokersCategories", new { id = categoryId }));
        }
コード例 #14
0
        public async Task <IActionResult> Create(int bbrokerId, int cclientId, int ttypeId, [Bind("Id,Number,Date,Sum,TypeId,ClientId,BrokerId")] Documents documents)
        {
            ViewBag.ClientDocId = cclientId;
            ViewBag.BrokerDocId = bbrokerId;
            ViewBag.TypeId      = ttypeId;
            if (ModelState.IsValid)
            {
                _context.Add(documents);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Documents", new { brokerId = bbrokerId, clientId = cclientId, typeId = ttypeId }));
            }

            return(RedirectToAction("Index", "Documents", new { brokerId = bbrokerId, clientId = cclientId, typeId = ttypeId }));
        }
コード例 #15
0
        public async Task <IActionResult> Create([Bind("Id,Name,Surname,BirthDate,PhoneNum,Adress,Passport,Email,Photo")] BrokerCreateEditModel brokerModel)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = null;
                if (brokerModel.Photo != null)
                {
                    string uploadFolder = Path.Combine(hostingEnvironment.WebRootPath, "brokerImages");
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + brokerModel.Photo.FileName;
                    string filePath   = Path.Combine(uploadFolder, uniqueFileName);
                    var    fileStream = new FileStream(filePath, FileMode.Create);
                    brokerModel.Photo.CopyTo(fileStream);
                    fileStream.Close();
                }
                if (brokerModel.Adress == null)
                {
                    brokerModel.Adress = "вул. Матеюка 20";
                }
                var client        = new MapsAPIClient("AIzaSyBfckBchOpn-lM4oJ9V9nBDBZmmlousIRQ");
                var geocodeResult = client.Geocoding.Geocode(brokerModel.Adress).Results.FirstOrDefault().Geometry.Location;

                Brokers newBroker = new Brokers
                {
                    Name         = brokerModel.Name,
                    Surname      = brokerModel.Surname,
                    BirthDate    = brokerModel.BirthDate,
                    PhoneNum     = brokerModel.PhoneNum,
                    Adress       = brokerModel.Adress,
                    GeoLatitude  = (Double)geocodeResult.Latitude,
                    GeoLongitude = (Double)geocodeResult.Longitude,
                    Passport     = brokerModel.Passport,
                    Email        = brokerModel.Email,
                    ImagePath    = uniqueFileName
                };
                _context.Add(newBroker);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brokerModel));
        }
        public async Task <IActionResult> CreateApplication(
            [Bind("ZipCode,EmploymentIncome,HouseholdMembers")] Subscriber _subscriber)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _subscriber.TimeStamp = DateTime.Now;
                    _context.Add(_subscriber);
                    await _context.SaveChangesAsync();

                    TempData["SubscriberId"] = _subscriber.SubscriberID;
                    return(RedirectToRoute("showplans"));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator." + ex.Message);
            }
            return(View(_subscriber));
        }
コード例 #17
0
        public async Task <IActionResult> PurchasePlanPost(int?id, IFormCollection collection)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var subscriberToUpdate = await _context.Subscribers.SingleOrDefaultAsync(s => s.SubscriberID == Convert.ToInt32(collection["SubscriberId"]));

            if (await TryUpdateModelAsync <Subscriber>(
                    subscriberToUpdate,
                    "",
                    s => s.FirstName, s => s.MiddleName, s => s.LastName, s => s.AddressLine1, s => s.AddressLine2, s => s.City, s => s.State, s => s.ZipCode, s => s.County, s => s.PhoneNumber, s => s.EmailAddress, s => s.SocialSecurityNumber, s => s.IsUSCitizen, s => s.IsMilitary, s => s.IsStudent, s => s.IsOnMedicare, s => s.IsOnDisability, s => s.EmploymentIncome, s => s.InvestmentIncome, s => s.AlimonyChildSupport))
            {
                try
                {
                    var _confirmation = RandomString(10);
                    var _enrollment   = new Enrollment {
                        InsurancePlanID = (int)id, PlanYear = DateTime.Now.Year, SubscriberID = Convert.ToInt32(collection["SubscriberId"]), ConfirmationCode = _confirmation, TimeStamp = DateTime.Now
                    };
                    TempData["confirmation"] = _confirmation;
                    _context.Add(_enrollment);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Confirm"));
                }
                catch (DbUpdateException ex)
                {
                    //Log the error (uncomment ex variable name and write a log.)
                    ModelState.AddModelError("", "Unable to save changes. " +
                                             "Try again, and if the problem persists, " +
                                             "see your system administrator." + ex.Message);
                }
            }

            return(View(subscriberToUpdate));
        }
コード例 #18
0
 public void InsertInsurance(Insurance insurance)
 {
     _context.Add(insurance);
     _context.SaveChanges();
 }