public async Task <IActionResult> Edit(int id, [Bind("Id,TypeHealth,Premium,AgreeDate,InsuredId,PolicyId")] HealthPolicy healthPolicy)
        {
            if (id != healthPolicy.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(healthPolicy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HealthPolicyExists(healthPolicy.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Address,PhoneNumber,HealthStatus")] Advisor advisor)
        {
            if (id != advisor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(advisor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdvisorExists(advisor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(advisor));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Surname,BirthDate,Passport,PhoneNum,Email")] Clients clients)
        {
            if (id != clients.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clients);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientsExists(clients.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clients));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,CaseNumber,Description,AccidentDate,UserId")] Case @case)
        {
            if (id != @case.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@case);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CaseExists(@case.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.User, "Id", "FirstName", @case.UserId);
            return(View(@case));
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(int id, int categoryId, [Bind("Id,BrokerId,CategoryId")] BrokersCategories brokersCategories)
        {
            if (id != brokersCategories.Id)
            {
                return(NotFound());
            }
            ViewBag.CategoryId = categoryId;
            ViewBag.BrokerId   = brokersCategories.BrokerId;

            try
            {
                _context.Update(brokersCategories);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BrokersCategoriesExists(brokersCategories.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction("Index", "BrokersCategories", new { id = categoryId }));

            // return RedirectToAction(nameof(Index));


            //return RedirectToAction("Index", "BrokersCategories", new { id = categoryId });
        }
Esempio n. 6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Category")] Categories categories)
        {
            if (id != categories.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categories);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoriesExists(categories.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categories));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Chassis,Registration,Power,Volume,Premium,VehicleColor,AgreeDate,PolicyId")] CascoPolicy cascoPolicy)
        {
            if (id != cascoPolicy.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cascoPolicy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CascoPolicyExists(cascoPolicy.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PolicyId"] = new SelectList(_context.Policy, "Id", "PolicyNumber", cascoPolicy.PolicyId);
            return(View(cascoPolicy));
        }
Esempio n. 8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PolicyNumber,PolicyType,OwnerId,AgentId")] Policy policy)
        {
            if (id != policy.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(policy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PolicyExists(policy.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
Esempio n. 9
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,BussinessName,BussinessAddress,BussinessPhoneNumber")] MGA mGA)
        {
            if (id != mGA.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mGA);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MGAExists(mGA.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mGA));
        }
Esempio n. 10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,AgentNumber,FirstName,LastName,PolicyCount,BirthDate,HireDate,ProfilePicture")] Agent agent)
        {
            if (id != agent.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgentExists(agent.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(agent));
        }
Esempio n. 11
0
        public async Task <IActionResult> Edit(int categoryId, int id, [Bind("Id,Type,CategoryId,Info")] Types types)
        {
            if (id != types.Id)
            {
                return(NotFound());
            }
            types.CategoryId     = categoryId;
            ViewBag.CategoryName = _context.Categories.Find(categoryId).Category;
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(types);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypesExists(types.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

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


            return(RedirectToAction("Index", "Types", new { id = categoryId, category = _context.Categories.Where(d => d.Id == categoryId).FirstOrDefault().Category }));
        }
Esempio n. 12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,EMBG,BirthDate")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Esempio n. 13
0
        public async Task <IActionResult> Edit(int id, int bDocId, int clDocId, int tDocId, [Bind("Id,Number,Date,Sum,TypeId,ClientId,BrokerId")] Documents documents)
        {
            ViewBag.ClientDocId = clDocId;
            ViewBag.BrokerDocId = bDocId;
            ViewBag.TypeDocId   = tDocId;
            if (id != documents.Id)
            {
                return(NotFound());
            }


            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(documents);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DocumentsExists(documents.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Documents", new { brokerId = bDocId, clientId = clDocId, typeId = tDocId }));
            }

            return(RedirectToAction("Index", "Documents", new { brokerId = bDocId, clientId = clDocId, typeId = tDocId }));
        }
Esempio n. 14
0
        public async Task <IActionResult> Edit(int id, [Bind("Name,Surname,BirthDate,PhoneNum,Passport,Adress,Email,Password,Photo, ImagePath")] BrokerCreateEditModel brokerModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var findbroker = await _context.Brokers.FindAsync(id);

                    string uniqueFileName = findbroker.ImagePath;
                    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();
                    }

                    findbroker.Name      = brokerModel.Name;
                    findbroker.Surname   = brokerModel.Surname;
                    findbroker.BirthDate = brokerModel.BirthDate;
                    findbroker.PhoneNum  = brokerModel.PhoneNum;
                    findbroker.Adress    = brokerModel.Adress;

                    /* if (brokerModel.Adress == "вул. Матеюка 20")
                     * {
                     *   findbroker.GeoLatitude = brokerModel.GeoLatitude;
                     *   findbroker.GeoLongitude = brokerModel.GeoLongitude;
                     * }
                     * else
                     * {*/
                    var client        = new MapsAPIClient("AIzaSyBfckBchOpn-lM4oJ9V9nBDBZmmlousIRQ");
                    var geocodeResult = client.Geocoding.Geocode(brokerModel.Adress).Results.FirstOrDefault().Geometry.Location;
                    findbroker.GeoLatitude  = (Double)geocodeResult.Latitude;
                    findbroker.GeoLongitude = (Double)geocodeResult.Longitude;
                    //}
                    findbroker.Passport = brokerModel.Passport;
                    findbroker.Email    = brokerModel.Email;

                    if (uniqueFileName != null)
                    {
                        string   FileName = findbroker.ImagePath;
                        string   ImPath   = Path.Combine(hostingEnvironment.WebRootPath, "brokerImages") + "\\" + FileName;
                        FileInfo file     = new FileInfo(ImPath);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                        findbroker.ImagePath = uniqueFileName;
                    }

                    _context.Update(findbroker);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BrokersExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var broker = _context.Brokers.Find(id);

            return(View(broker));
        }