public async Task <IActionResult> Create(EmployeesViewModel employees)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (employees.ProfileImage != null)
                    {
                        if (employees.ProfileImage.Length > 0)
                        {
                            using (var oStream = employees.ProfileImage.OpenReadStream())
                                using (var mStream = new MemoryStream())
                                {
                                    oStream.CopyTo(mStream);
                                    employees.PicArray = mStream.ToArray();
                                }
                        }
                    }
                }
                catch (Exception)
                {
                    //Log error
                }

                _context.Add(EmployeesViewModel.ConvertViewModel(employees));
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employees));
        }
 public async Task <IActionResult> Edit(EmployeesViewModel employees)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (employees.ProfileImage != null)
             {
                 if (employees.ProfileImage.Length > 0)
                 {
                     using (var oStream = employees.ProfileImage.OpenReadStream())
                         using (var mStream = new MemoryStream())
                         {
                             oStream.CopyTo(mStream);
                             employees.PicArray = mStream.ToArray();
                         }
                 }
             }
             _context.Update(EmployeesViewModel.ConvertViewModel(employees));
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!EmployeesExists(employees.Employee.EmpId))
             {
                 return(NotFound());
             }
             else
             {
                 //Log error
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(employees));
 }