public async Task <JsonResult> Comments(string data, long recordId)
        {
            var CurrentUserEmial = User.Identity.Name;
            var FirstName        = adamUnit.AppUserRepository.SingleOrDefault(x => x.Email == CurrentUserEmial).FirstName;
            var LastName         = adamUnit.AppUserRepository.SingleOrDefault(x => x.Email == CurrentUserEmial).LastName;
            var CurrentUserId    = adamUnit.AppUserRepository.SingleOrDefault(x => x.Email == CurrentUserEmial).Id;

            if (User.IsInRole(AppHelper.SuperAdminEndUser))
            {
                var Attacment = adamUnit.AttachmentRepository.SingleOrDefault(x => x.OwnerId == CurrentUserId).FileName;
                var comment   = new Comment();
                comment.TableId   = recordId;
                comment.TableName = TableName.Project;
                comment.context   = data;
                comment.UserId    = CurrentUserId;
                await adamUnit.CommentRepository.InserAsync(comment);

                // Ids of employee Joined to Project and send Notify to them by Admin
                var employeeIds = adamUnit.ProjectUserRepository.GetAll(x => x.ProjectId == recordId).Select(x => x.UserId)
                                  .ToList();
                foreach (var empId in employeeIds)
                {
                    var notify = new Notfication();
                    notify.OwnerUserId = CurrentUserId;
                    notify.ToUserId    = adamUnit.EmployeeRepository.SingleOrDefault(x => x.Id == empId).UserId;
                    notify.TableName   = TableName.Project;
                    notify.TablePkId   = recordId;
                    notify.Context     = "AddComment";
                    await adamUnit.NotificationRepository.InserAsync(notify);

                    var url = "/Admin/Project/Details?id=" + recordId;
                    if (adamUnit.TokenFireBaseRepository.Exists(x => x.UserId == notify.ToUserId))
                    {
                        var tokens = adamUnit.TokenFireBaseRepository.GetAll(x => x.UserId == notify.ToUserId).Select(x => x.token);
                        foreach (var token in tokens)
                        {
                            NotificationController.SendPushNotification(token, notify.Context, FirstName, url, Attacment);
                        }
                    }
                }

                var idDb = comment.Id;
                return(Json(new { id = comment.Id, firstName = FirstName, lastName = LastName, attacment = Attacment, date = DateTime.Now.ToShortTimeString() }));
            }
            else
            {
                var employeeId = adamUnit.EmployeeRepository.SingleOrDefault(x => x.UserId == CurrentUserId).Id;
                var Attacment  = adamUnit.AttachmentRepository.SingleOrDefault(x => x.OwnerId == employeeId.ToString()).FileName;
                var comment    = new Comment();
                comment.TableId   = recordId;
                comment.TableName = TableName.Project;
                comment.context   = data;
                comment.UserId    = CurrentUserId;
                await adamUnit.CommentRepository.InserAsync(comment);

                // Ids of employee Joined to Project and send Notify to them by Employee
                var employeeIds = adamUnit.ProjectUserRepository.GetAll(x => x.ProjectId == recordId && x.UserId != employeeId).Select(x => x.UserId)
                                  .ToList();
                if (employeeIds.Count > 1)
                {
                    foreach (var empId in employeeIds)
                    {
                        var UserId = adamUnit.EmployeeRepository.SingleOrDefault(x => x.Id == empId && x.UserId != CurrentUserId).UserId;

                        if (UserId != null)
                        {
                            var notify = new Notfication();
                            notify.OwnerUserId = CurrentUserId;
                            notify.ToUserId    = UserId;
                            notify.TableName   = TableName.Project;
                            notify.TablePkId   = recordId;
                            notify.Context     = "AddComment";
                            await adamUnit.NotificationRepository.InserAsync(notify);

                            var url = "/Admin/Project/Details?id=" + recordId;
                            if (adamUnit.TokenFireBaseRepository.Exists(x => x.UserId == UserId))
                            {
                                var tokens = adamUnit.TokenFireBaseRepository.GetAll(x => x.UserId == UserId).Select(x => x.token);
                                foreach (var token in tokens)
                                {
                                    NotificationController.SendPushNotification(token, notify.Context, FirstName, url, Attacment);
                                }
                            }
                        }
                    }
                }
                // save and send Notification to Admin By Employee
                // UserId of Admin
                var UserIdOfAdmin = adamUnit.RoleRepository.GetUserIdOfRole();
                var notfy         = new Notfication();
                notfy.OwnerUserId = CurrentUserId;
                notfy.ToUserId    = UserIdOfAdmin;
                notfy.TableName   = TableName.Project;
                notfy.TablePkId   = recordId;
                notfy.Context     = "AddComment";
                await adamUnit.NotificationRepository.InserAsync(notfy);

                var Url = "/Admin/Project/Details?id=" + recordId;
                if (adamUnit.TokenFireBaseRepository.Exists(x => x.UserId == UserIdOfAdmin))
                {
                    var tokens = adamUnit.TokenFireBaseRepository.GetAll(x => x.UserId == UserIdOfAdmin).Select(x => x.token);
                    foreach (var token in tokens)
                    {
                        NotificationController.SendPushNotification(token, notfy.Context, FirstName, Url, Attacment);
                    }
                }
                return(Json(new { id = comment.Id, firstName = FirstName, lastName = LastName, attacment = Attacment, date = DateTime.Now.ToShortTimeString() }));
            }
        }
        public async Task <IActionResult> Create(List <IFormFile> files, ProjectVM projectVm)
        {
            if (!adamUnit.ProjectRepository.Exists(x => x.Name == projectVm.Name))
            {
                // Current login User Information
                var CurrentUserEmial = User.Identity.Name;
                var CurrentUserId    = adamUnit.AppUserRepository.SingleOrDefault(x => x.Email == CurrentUserEmial).Id;
                var CurrentName      = adamUnit.AppUserRepository.SingleOrDefault(x => x.Email == CurrentUserEmial).FirstName;
                if (!ModelState.IsValid)
                {
                    return(View(projectVm));
                }
                var project = new Models.Project();
                project = projectVm.ToEntity();
                await adamUnit.ProjectRepository.InserAsync(project);

                var ProjId = project.Id;
                //save UserInProjUser
                string[] array = Regex.Split(projectVm.EmpIds, ",");
                foreach (var item in array)
                {
                    var ProjUser = new ProjectUser();
                    ProjUser.ProjectId = ProjId;
                    ProjUser.UserId    = Convert.ToInt64(item);
                    await adamUnit.ProjectUserRepository.InserAsync(ProjUser);
                }
                string webRootPath = _hostingEnvironment.WebRootPath;
                var    state       = adamUnit.AttachmentRepository.OnPostUpload(files, ProjId.ToString(),
                                                                                AttachmentOwner.Projects, AttachmentType.Photo, webRootPath);
                //send Notification To Users
                foreach (var item in array)
                {
                    var UserId     = adamUnit.EmployeeRepository.SingleOrDefault(x => x.Id == Convert.ToInt16(item)).UserId;
                    var UserName   = adamUnit.AppUserRepository.SingleOrDefault(x => x.Id == UserId).UserName;
                    var attachment = adamUnit.AttachmentRepository.FirstOrDefault(x => x.OwnerId == item).FileName;
                    var notify     = new Notfication();
                    notify.OwnerUserId = CurrentUserId;
                    notify.ToUserId    = UserId;
                    notify.TableName   = TableName.Project;
                    notify.TablePkId   = ProjId;
                    notify.Context     = "AddyouToProject";
                    var Url = "/Admin/Project/Details?id=" + ProjId;
                    await adamUnit.NotificationRepository.InserAsync(notify);

                    if (adamUnit.TokenFireBaseRepository.Exists(x => x.UserId == UserId))
                    {
                        var tokens = adamUnit.TokenFireBaseRepository.GetAll(x => x.UserId == UserId).Select(x => x.token);
                        foreach (var token in tokens)
                        {
                            NotificationController.SendPushNotification(token, notify.Context, CurrentName, Url, attachment);
                        }
                    }
                }
                TempData["SuccessMessage"] = "Created Successfully";
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.Name     = "Name is Exist Already";
            ViewBag.Customer = adamUnit.CustomerRepository.GetAll().ToList();
            ViewBag.Employee = adamUnit.EmployeeRepository.GetAllInclude().ToList();
            return(View(projectVm));
        }