コード例 #1
0
        public async Task <IActionResult> PutClients(int id, Clients clients)
        {
            if (id != clients.Id)
            {
                return(BadRequest());
            }

            _context.Entry(clients).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(clients));
        }
コード例 #2
0
        public async Task <Policy> CreatePolicy(Policy policy)
        {
            try
            {
                policy.PolicyId = null;
                if (CostRiskValidation.CostRiskValidator(policy))
                {
                    _context.Policies.Add(new Policy
                    {
                        Description        = policy.Description,
                        Name               = policy.Name,
                        PolicyCost         = policy.PolicyCost,
                        PolicyDateBegin    = policy.PolicyDateBegin,
                        PolicyId           = policy.PolicyId,
                        PolicyMonthsPeriod = policy.PolicyMonthsPeriod,
                        PolicyTypeId       = policy.PolicyTypeId,
                        RiskTypeId         = policy.RiskTypeId
                    });
                    await _context.SaveChangesAsync();
                }
            }
            catch (CostRiskException e)
            {
                throw e;
            }

            return(policy);
        }
コード例 #3
0
        public async Task <IActionResult> PutBrokersCategories(int id, BrokersCategories brokersCategories)
        {
            if (id != brokersCategories.Id)
            {
                return(BadRequest());
            }

            _context.Entry(brokersCategories).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BrokersCategoriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(brokersCategories));
        }
コード例 #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,Name,Surname,BirthDate,Passport,PhoneNum,Email")] Clients clients)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clients);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clients));
        }
コード例 #6
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));
        }
コード例 #7
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));
        }
コード例 #8
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));
        }
コード例 #9
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));
        }
コード例 #10
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));
        }
コード例 #11
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));
        }
コード例 #12
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));
        }
コード例 #13
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));
        }
コード例 #14
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 }));
        }
コード例 #15
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 }));
        }
コード例 #16
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 }));
        }
コード例 #17
0
        public async Task <List <ClientPolicy> > AddOrUpdateClientPolicies(ClientPolicies clientPolicies)
        {
            List <ClientPolicy> clientPolicyListSaved = await _context.ClientPolicies.Where(cp => cp.ClientId == clientPolicies.ClientId).ToListAsync();

            List <ClientPolicy> clientPoliciesToAdd    = new List <ClientPolicy>();
            List <ClientPolicy> clientPoliciesToDelete = new List <ClientPolicy>();

            if (clientPolicyListSaved.Count > 0)
            {
                clientPolicyListSaved.ForEach(client =>
                {
                    if (clientPolicies.PoliciesIds.Contains(client.PolicyId) == false)
                    {
                        clientPoliciesToDelete.Add(client);
                    }
                });
            }
            clientPolicies.PoliciesIds.ForEach(id =>
            {
                ClientPolicy clientPolicy = clientPolicyListSaved.Find(e => e.ClientId == clientPolicies.ClientId && e.PolicyId == id);
                if (clientPolicy == null)
                {
                    clientPoliciesToAdd.Add(new ClientPolicy {
                        ClientId = clientPolicies.ClientId, PolicyId = id
                    });
                }
            });
            await _context.ClientPolicies.AddRangeAsync(clientPoliciesToAdd);

            _context.ClientPolicies.RemoveRange(clientPoliciesToDelete);
            await _context.SaveChangesAsync();

            return(await _context.ClientPolicies.Where(cp => cp.ClientId == clientPolicies.ClientId).ToListAsync());
        }
コード例 #18
0
        public async Task <ActionResult <Insurance> > Create(Insurance insurance)
        {
            _context.Insurances.Add(insurance);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(null, new { id = insurance.Id }, insurance));
        }
コード例 #19
0
        public async Task <ActionResult <IEnumerable <Insurance> > > Get()
        {
            var insurance = _factory.CreateClaims();
            await _context.Insurances.AddAsync(insurance);

            await _context.SaveChangesAsync();

            return(Ok(insurance));
        }
コード例 #20
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));
        }
コード例 #21
0
        public async Task <User> RegisterUser(User user)
        {
            User userExist = _context.Users.FirstOrDefault(u => u.UserName == user.UserName);

            if (userExist != null)
            {
                return(null);
            }
            string savedPasswordHash = CryptoUtils.TransformPassword(user.Password);

            user = _context.Users.Add(new User
            {
                UserName     = user.UserName,
                FullName     = user.FullName,
                PasswordHash = savedPasswordHash,
                Role         = user.Role
            }).Entity;

            await _context.SaveChangesAsync();

            return(user);
        }
        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));
        }
コード例 #23
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));
        }