Пример #1
0
        public async Task <string> CheckAvaibality(CheckAvaibalityDto data)
        {
            var query1 = await HelpDeskContext.Set <UserModel>()
                         .Where(u => u.UserName.Equals(data.UserName.ToString())).FirstOrDefaultAsync();

            var query2 = await HelpDeskContext.Set <UserModel>()
                         .Where(u => u.Email.Equals(data.Email.ToString())).FirstOrDefaultAsync();

            if (query1 == null && query2 == null)
            {
                return("NotTakenYet");
            }
            else if (query1 != null)
            {
                return("UserName_AlreadyTaken");
            }
            else if (query2 != null)
            {
                return("Email_AlreadyTaken");
            }
            else
            {
                return("Both_AlreadyTaken");
            }
        }
Пример #2
0
        public async Task <DashboardMainInformationDto> GetDashboardDetails(string userType)
        {
            var details = new DashboardMainInformationDto();

            if (userType == "HelpDesk")
            {
                var totalTickets = await HelpDeskContext.Set <TicketModel>().CountAsync();

                var OpenTickets = await HelpDeskContext.Set <TicketModel>()
                                  .Where(t => t.TktStatus.Equals("Open".ToString())).CountAsync();

                var closedTickets = await HelpDeskContext.Set <TicketModel>()
                                    .Where(t => t.TktStatus.Equals("Closed".ToString())).CountAsync();

                var inprogressTickets = await HelpDeskContext.Set <TicketModel>()
                                        .Where(t => t.TktStatus.Equals("in-progress".ToString())).CountAsync();

                var companies = await HelpDeskContext.Set <CompanyModel>()
                                .ToListAsync();

                foreach (var company in companies)
                {
                    var companyDetails = new DashboardCompanyDetailsDto();

                    var totalTicketsInCompany = await HelpDeskContext.Set <TicketModel>()
                                                .Where(t => t.CompanyId.Equals(company.CompanyId)).CountAsync();

                    var OpenTicketsInCompany = await HelpDeskContext.Set <TicketModel>()
                                               .Where(t => t.CompanyId.Equals(company.CompanyId) & t.TktStatus.Equals("Open".ToString())).CountAsync();

                    var closedTicketsInCompany = await HelpDeskContext.Set <TicketModel>()
                                                 .Where(t => t.CompanyId.Equals(company.CompanyId) & t.TktStatus.Equals("Closed".ToString())).CountAsync();

                    var inprogressTicketsInCompany = await HelpDeskContext.Set <TicketModel>()
                                                     .Where(t => t.CompanyId.Equals(company.CompanyId) & t.TktStatus.Equals("in-progress".ToString())).CountAsync();

                    companyDetails.CompanyId              = company.CompanyId;
                    companyDetails.CompanyName            = company.CompanyName;
                    companyDetails.TotalTickets           = totalTicketsInCompany;
                    companyDetails.TotalOpenTickets       = OpenTicketsInCompany;
                    companyDetails.TotalClosedTickets     = closedTicketsInCompany;
                    companyDetails.TotalInprogressTickets = inprogressTicketsInCompany;

                    details.DashboardCompanyDeatails.Add(companyDetails);
                }



                details.ClosedTickets = closedTickets;
                details.OpenTickets   = OpenTickets;
                details.TotalTickets  = totalTickets;
                details.inprogress    = inprogressTickets;

                return(details);
            }

            return(null);
        }
Пример #3
0
 public async Task <UserModel> LoginUser(UserLoginDto userLoginDto)
 {
     return(await HelpDeskContext.Set <UserModel>()
            .Where(
                u => u.UserName.Equals(userLoginDto.UserNameOrEmail.ToString()) ||
                u.Email.Equals(userLoginDto.UserNameOrEmail.ToString())
                )
            .Where(u => u.PasswordHash.Equals(userLoginDto.Password.ToString()))
            .FirstOrDefaultAsync());
 }
Пример #4
0
        public bool Delete(int id)
        {
            var entity = db.Set <T>().FirstOrDefault(x => x.ID == id);

            if (entity != null)
            {
                entity.DeletedDate = DateTime.Now;
                entity.IsDeleted   = true;
                db.SaveChanges();
                return(true);
            }

            return(false);
        }
Пример #5
0
        public async Task <List <CompanyDto> > GetCompanyDetails(IEnumerable <CompanyModel> companies)
        {
            var companiesDetails = new List <CompanyDto>();

            if (companies != null)
            {
                foreach (var company in companies)
                {
                    var companyDetails = new CompanyDto();
                    companyDetails.CompanyId   = company.CompanyId;
                    companyDetails.CompanyName = company.CompanyName;

                    var numOfTickets = await HelpDeskContext.Set <TicketModel>()
                                       .Where(t => t.CompanyId.Equals(company.CompanyId.ToString())).CountAsync();

                    var numOfProducts = await HelpDeskContext.Set <ProductModel>()
                                        .Where(t => t.CompanyId.Equals(company.CompanyId.ToString())).CountAsync();

                    var numOfCategories = await HelpDeskContext.Set <CategoryModel>()
                                          .Where(t => t.CompanyId.Equals(company.CompanyId.ToString())).CountAsync();

                    var numOfModules = await HelpDeskContext.Set <ModuleModel>()
                                       .Where(t => t.CompanyId.Equals(company.CompanyId.ToString())).CountAsync();

                    var numOfBrands = await HelpDeskContext.Set <CompanyBrandModel>()
                                      .Where(t => t.CompanyId.Equals(company.CompanyId.ToString())).CountAsync();

                    companyDetails.NumOfTickets    = numOfTickets;
                    companyDetails.NumOfCategories = numOfCategories;
                    companyDetails.NumOfModules    = numOfModules;
                    companyDetails.NumOfBrands     = numOfBrands;
                    companyDetails.NumOfProducts   = numOfProducts;

                    companiesDetails.Add(companyDetails);
                }
                return(companiesDetails);
            }
            return(null);
        }
 public virtual void Add(TDomain entity)
 {
     _context.Set <TDomain>().Add(entity);
 }
Пример #7
0
 public void Add(TEndity obj)
 {
     Db.Set <TEndity>().Add(obj);
     Db.SaveChanges();
 }
Пример #8
0
 public GenericRepository()
 {
     db         = new HelpDeskContext();
     _dbcontext = db.Set <T>();
 }