public async Task <IActionResult> Create([Bind("Id,ImagePath,ImageTitle,Title,SubTitle,Text,SubText,Phone,OtherPhone,Email,SiteAddress,Address,ServiceId")] Insuarance insuarance, IFormFile ImagePath)
        {
            CustomDateTimeFile customDateTimeFile = new CustomDateTimeFile();
            string             fileName           = customDateTimeFile.GetFileName(ImagePath.FileName);

            if (ModelState.IsValid)
            {
                insuarance.ImagePath = fileName;
                if (_IsAcceptedFormat(ImagePath.ContentType))
                {
                    string path = Path.Combine(hostingEnvironment.WebRootPath, "images", fileName);
                    byte[] data = new byte[ImagePath.Length];

                    using (FileStream fileStream = new FileStream(path, FileMode.Create))
                    {
                        await ImagePath.CopyToAsync(fileStream);
                    }
                }
                await _context.AddAsync(insuarance);

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Id", insuarance.ServiceId);
            return(View(insuarance));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ImagePath,ImageTitle,Title,SubTitle,Text,SubText,Phone,OtherPhone,Email,SiteAddress,Address,ServiceId")] Insuarance insuarance)
        {
            if (id != insuarance.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(insuarance);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InsuaranceExists(insuarance.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ServiceId"] = new SelectList(_context.Services, "Id", "Id", insuarance.ServiceId);
            return(View(insuarance));
        }