public ActionResult GetEmployeeID()
        {
            int         data     = db.A_Employees.ToList().Count;
            A_Employees employee = new A_Employees()
            {
                Employee_ID = (data + 1)
            };

            db.A_Employees.Add(employee);
            db.SaveChanges();
            data += 1;
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SavePhoto(IEnumerable <HttpPostedFileBase> uploadbox, int?EmployeeID)
        {
            if (uploadbox != null)
            {
                foreach (HttpPostedFileBase file in uploadbox)
                {
                    string fileName        = Path.GetFileName(file.FileName);
                    string destinationPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
                    file.SaveAs(destinationPath);
                    string       filePath  = destinationPath;              // getting the file path of uploaded file
                    string       filename1 = Path.GetFileName(filePath);   // getting the file name of uploaded file
                    string       ext       = Path.GetExtension(filename1); // getting the file extension of uploaded file
                    string       type      = string.Empty;
                    Stream       fs        = file.InputStream;
                    BinaryReader br        = new BinaryReader(fs);         //reads the binary files
                    byte[]       bytes     = br.ReadBytes((int)fs.Length); //counting the file length into bytes
                    A_Employees  exists    = db.A_Employees.FirstOrDefault(o => o.Employee_ID == EmployeeID);
                    if (exists != null)
                    {
                        exists.Photo           = bytes;
                        db.Entry(exists).State = System.Data.Entity.EntityState.Modified;
                    }
                    db.SaveChanges();

                    //int count = context.A_DocumentUpload.ToList().Count;
                    //A_DocumentUpload doc = new A_DocumentUpload()
                    //{
                    //    MeetingNo = meetingNo,
                    //    DecisionType = decisionType,
                    //    DocumentFile = bytes,
                    //    UploadDate = DateTime.Now,
                    //    DocumentName = filename1,
                    //    DocumentCode = (count + 1),
                    //    File_extension = ext
                    //};
                    //context.A_DocumentUpload.Add(doc);
                    //context.SaveChanges();
                }
            }

            return(Content(""));
        }
        public ActionResult EmployeeUpdate(A_Employees value)
        {
            A_Employees exists = db.A_Employees.FirstOrDefault(o => o.Employee_ID == value.Employee_ID);

            if (exists != null)
            {
                exists.EditedBy        = User.Identity.Name;
                exists.EditionDate     = DateTime.Now.Date;
                exists.Company         = value.Company;
                exists.CreatedBy       = value.CreatedBy;
                exists.CreationDate    = value.CreationDate;
                exists.Date_Of_Birth   = value.Date_Of_Birth;
                exists.Email           = value.Email;
                exists.Gender          = value.Gender;
                exists.Name            = value.Name;
                exists.Nationality     = value.Nationality;
                exists.NIN_No          = value.NIN_No;
                exists.Phone           = value.Phone;
                exists.Telephone       = value.Telephone;
                exists.Title           = value.Title;
                db.Entry(exists).State = System.Data.Entity.EntityState.Modified;
            }
            else
            {
                int         count = 0;
                A_Employees data  = db.A_Employees.OrderByDescending(o => o.Employee_ID).ToList().FirstOrDefault();
                if (data != null)
                {
                    count = data.Employee_ID;
                }

                value.Employee_ID  = (count + 1);
                value.CreatedBy    = User.Identity.Name;
                value.CreationDate = DateTime.Now.Date;
                db.A_Employees.Add(value);
            }
            db.SaveChanges();
            return(Json(value, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CancelEmployeeAdd(int employeeID)
        {
            string      result = "There was nothing to delete";
            A_Employees data   = db.A_Employees.FirstOrDefault(o => o.Employee_ID == employeeID);

            if (data != null)
            {
                db.A_Employees.Remove(data);
                List <Education> educ = db.Educations.Where(o => o.EmployeeID == employeeID).ToList();
                if (educ.Count > 0)
                {
                    db.Educations.RemoveRange(educ);
                }
                List <Employee_NOK> nok = db.Employee_NOK.Where(o => o.Employee_ID == employeeID).ToList();
                if (nok.Count > 0)
                {
                    db.Employee_NOK.RemoveRange(nok);
                }
                db.SaveChanges();
                result = "Deleted successfully";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }