public ResponseMessage DeleteSelectedEmployees(List<string> employees)
        {
            ResponseMessage responseMessage = new ResponseMessage();
            List<EmployeeModel> employeeModel = new List<EmployeeModel>();
            try
            {

                foreach (var i in employees)
                {
                    var id = i;
                    if (id != null)
                    {

                        List<UserLocationModel> model = new List<UserLocationModel>();
                        model = userLocationService.FindLocationListById(id);
                        foreach (var item in model)
                        {
                            userLocationService.DeleteUserLocation(item.UserLocationId);
                        }

                        serviceProviderEmployeeMappingService.DeleteServiceProviderEmployeeMapping(id);
                        //var job = jobService.GetJobListByEmployeeId(id);
                        //job.ForEach(x =>
                        //{
                        //    jobService.DeleteJob(x.JobId);
                        //});
                        employeeService.DeleteEmployee(id);
                        var serviceProvider = serviceProviderService.GetServiceProviderById(id);
                        if (serviceProvider.CompanyName != null)
                            serviceProviderService.DeleteServiceProvider(id);

                        ApplicationUser user = UserManager.FindById(id);

                        IdentityResult result = UserManager.Delete(user);

                    }
                }

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                responseMessage.Message = ex.Message.ToString();
                return responseMessage;
            }
            employeeModel = employeeService.GetAllEmployees().ToList();
            responseMessage.totalRecords = employeeModel.Count();
            responseMessage.Message = "Employees has been deleted successfully.";
            return responseMessage;
        }
Exemple #2
0
        public ResponseMessage Paging(PagingModel model)
        {
            ResponseMessage responseMessage = new ResponseMessage();
            List<TransactionHistoryModel> transactionHistoryModel = new List<TransactionHistoryModel>();
            transactionHistoryModel = transactionHistoryService.Paging(model);
            responseMessage.totalRecords = transactionHistoryModel.Count();
            transactionHistoryModel = transactionHistoryModel.OrderBy(x => x.CustomerEmail).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList();
            transactionHistoryModel.ForEach(x => {
                JobModel jobModel = new JobModel();
                ServiceProviderModel serviceProviderModel = new ServiceProviderModel();
                if (x.JobId > 0)
                {

                    jobModel = jobService.GetJobById(x.JobId);
                }
                serviceProviderModel = serviceProviderService.GetServiceProviderById(jobModel.ServiceProviderId);
                x.ServiceProviderName = serviceProviderModel.CompanyName;
            });
            responseMessage.data = transactionHistoryModel;

            return responseMessage;
        }
        public ResponseMessage Paging(PagingModel model)
        {
            ResponseMessage responseMessage = new ResponseMessage();
            List<EmployeeModel> employeeModel = new List<EmployeeModel>();
            employeeModel = employeeService.Paging(model);
            //var ids = employeeModel.Select(x => x.EmployeeId).ToList();
            ServiceProviderEmployeeMappingService service = new ServiceProviderEmployeeMappingService();

            responseMessage.totalRecords = employeeModel.Count();
            employeeModel = employeeModel.OrderBy(x => x.FirstName).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList();
            employeeModel = service.GetServiceProviderByEmployeeId(employeeModel);
            responseMessage.data = employeeModel;

            return responseMessage;
        }
Exemple #4
0
        public ResponseMessage Paging(PagingModel model)
        {
            ResponseMessage responseMessage = new ResponseMessage();
            List<JobModel> jobModel = new List<JobModel>();
            jobModel = jobService.Paging(model);
            responseMessage.totalRecords = jobModel.Count();
            jobModel = jobModel.OrderBy(x => x.Description).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList();
            responseMessage.data = jobModel;

            return responseMessage;
        }
        public ResponseMessage DeleteSelectedComplaints(List<string> complaints)
        {
            ResponseMessage responseMessage = new ResponseMessage();
            List<ComplaintModel> complaintModelList = new List<ComplaintModel>();
            ComplaintModel complaintModel = new ComplaintModel();
            try
            {

                foreach (var i in complaints)
                {
                    var id =Convert.ToInt32(i);
                    if (id >0)
                    {
                        //Delete Complaint
                        complaintService.DeleteComplaint(Convert.ToInt32(id));
                    }
                }

            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                responseMessage.Message = ex.Message.ToString();
                return responseMessage;
            }

            responseMessage.Message = "Selected complaints deleted successfully.";
            return responseMessage;
        }
        public ResponseMessage RolesPaging(PagingModel model)
        {
            ResponseMessage responseMessage = new ResponseMessage();

            string searchparam = model.SearchText == null ? "" : model.SearchText;
            List<RoleBindingModel> roles;
            URFXDbContext db = new URFXDbContext();
            if (searchparam == "")
            {

                roles = db.Roles.Select(x => new RoleBindingModel() { Id = x.Id, Name = x.Name }).ToList();
            }
            else
            {
                roles = db.Roles.Select(x => new RoleBindingModel() { Id = x.Id, Name = x.Name }).Where(y => y.Name.ToLower().Contains(searchparam.ToLower())).ToList();
            }
            responseMessage.totalRecords = roles.Count();
            roles = roles.OrderBy(x => x.Name).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList();
            responseMessage.data = roles;

            return responseMessage;
        }
        public ResponseMessage Paging(PagingModel model)
        {
            
            ResponseMessage responseMessage = new ResponseMessage();
            var context = new URFXDbContext();
            var role = context.Roles.Where(x => x.Name == URFXRoles.Admin.ToString()).SingleOrDefault();
            string searchparam = model.SearchText == null ? "" : model.SearchText;
            List<ApplicationUser> users = UserManager.Users.Where(x => (x.Roles.Where(r => r.RoleId != role.Id).Count() > 0)).ToList();
            users.ForEach(x => {
                var roles = UserManager.GetRoles(x.Id);
                var userRole = roles.FirstOrDefault();
                x.Role = userRole;
            });
           
            if (searchparam != "")
            {
                users = users.Where(x => x.Email.ToLower().Contains(searchparam.ToLower())).ToList();
            }


            responseMessage.totalRecords = users.Count();
            users = users.OrderBy(x => x.UserName).Skip((model.CurrentPageIndex - 1) * model.PageSize).Take(model.PageSize).ToList();
            responseMessage.data = users;

            return responseMessage;
        }