Exemplo n.º 1
0
        public List <MissingModel> GetAllMissingModels(MissingModel model)
        {
            var mmList = new List <MissingModel>();

            using (var db = new practiceEntities())
            {
                var missingList = db.Missings
                                  .Include(x => x.Office)
                                  .Include(x => x.User)
                                  .Where(x => x.VerifyStatus == "V")
                                  .OrderByDescending(x => x.verifydate)
                                  .ToList();

                var missingModelList = Mapper.MissingMapper.MissingListToMissingModelList(missingList);

                mmList.AddRange(missingModelList);

                foreach (var missingModel in mmList)
                {
                    missingModel.PDistrictName = missingModel.PDistrictId != null?
                                                 db.Districts.SingleOrDefault(x => x.Id == missingModel.PDistrictId)?.DistrictNameEng : "";

                    missingModel.MDistrictName = missingModel.MDistrictId != null?
                                                 db.Districts.SingleOrDefault(x => x.Id == missingModel.MDistrictId)?.DistrictNameEng : "";

                    missingModel.PMunicipalityName = missingModel.PMunicipalityId != null?
                                                     db.Municipalities.SingleOrDefault(x => x.Id == missingModel.PMunicipalityId)?.MunicipalityName : "";


                    missingModel.MMunicipalityName = missingModel.MMunicipalityId != null?
                                                     db.Municipalities.SingleOrDefault(x => x.Id == missingModel.MMunicipalityId)?.MunicipalityName : "";
                }
                return(missingModelList);
            }
        }
Exemplo n.º 2
0
        public List <MissingModel> GetAllMissingUnApprovedRecords(int officeId)
        {
            using (var context = new practiceEntities())
            {
                var missingModelList = context.Missings
                                       .Include(x => x.User)
                                       .Include(x => x.Office)
                                       .Where(x => x.VerifyStatus.ToUpper() == "V" && x.OfficeId == officeId)
                                       .OrderByDescending(x => x.Id)
                                       .Select(x => new MissingModel
                {
                    RegistrationNumber = x.RegistrationNumber,
                    Id                    = x.Id,
                    OfficeName            = x.Office.OfficeName,
                    Fname                 = x.Fname,
                    Lname                 = x.Lname,
                    EnteredDate           = x.EnteredDate,
                    LastSeenDate          = x.LastSeenDate,
                    Photo                 = x.Photo,
                    ComplainByName        = x.ComplainByName,
                    ComplainContactNumber = x.ComplainContactNumber,
                    MissingStatus         = x.MissingStatus,
                    OfficeId              = x.OfficeId,
                    UserId                = x.UserId,
                    VerifyStatus          = x.VerifyStatus,
                    verifydate            = x.verifydate,
                    VerifyUserId          = x.VerifyUserId,
                    VerifyMessage         = x.VerifyMessage,
                })
                                       .ToList();

                return(missingModelList);
            }
        }
Exemplo n.º 3
0
        public int GetMenuId(string controllerName)
        {
            try
            {
                using (DB = new practiceEntities())
                {
                    var menu = DB.Menus.FirstOrDefault(x => x.Controller == controllerName);

                    if (menu != null)
                    {
                        return(menu.Id);
                    }

                    else
                    {
                        return(0);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                return(0);
            }
        }
Exemplo n.º 4
0
        public RoleAccess GetRoleAccessByMenuIdAndRoleId(int menuId, int roleId)
        {
            using (DB = new practiceEntities())
            {
                var roleAccess = DB.RoleAccesses.FirstOrDefault(a => a.MenuId == menuId && a.RoleId == roleId);

                return(roleAccess);
            }
        }
Exemplo n.º 5
0
        public string GetOfficeNameById(int officeId)
        {
            using (DB = new practiceEntities())
            {
                var office = DB.Offices.FirstOrDefault(x => x.Id == officeId);

                var text = office != null ? office.OfficeName : "";

                return(text);
            }
        }
Exemplo n.º 6
0
        public List <OfficeModel> GetAllT()
        {
            var practice = new practiceEntities();

            var officeList = practice.Offices
                             .Include(x => x.OfficeType)
                             .OrderBy(x => x.OfficeName)
                             .ToList();

            var officeModelList = Mapper.OfficeMapper.OfficeToOfficeModelList(officeList);

            return(officeModelList);
        }
Exemplo n.º 7
0
        public MunicipalityModel GetOneMunicipalityRecord(int id)
        {
            using (practiceEntities db = new practiceEntities())
            {
                var municipality = db.Municipalities
                                   .Include(x => x.District)
                                   .Include(m => m.MunicipalityType).SingleOrDefault(x => x.Id == id);

                var muncipalityModel = Mapper.MuncipalityMapper.MuncipalityToMuncipalityModel(municipality);

                return(muncipalityModel);
            }
        }
Exemplo n.º 8
0
        public List <MunicipalityModel> GetAllMunicipalityRecord()
        {
            using (practiceEntities db = new practiceEntities())
            {
                var municipalityList = db.Municipalities
                                       .Include(d => d.District)
                                       .Include(m => m.MunicipalityType)
                                       .OrderByDescending(x => x.Id)
                                       .ToList();

                var municipalityModelList = Mapper.MuncipalityMapper.MunicipalityToMunicipalityModelList(municipalityList);

                return(municipalityModelList);
            }
        }
Exemplo n.º 9
0
        public void AddDocument(DocumentModel doc)
        {
            doc.Tables.Add(doc.HeadTable);
            Document dbDoc = new Document();

            using (var db = new practiceEntities())
            {
                db.Configuration.AutoDetectChangesEnabled = false;

                dbDoc.Acts = ConvertActsToDbActs(doc.Acts);
                dbDoc.Tables = ConvertToDbTables(doc.Tables);
                db.Documents.Add(dbDoc);
                db.ChangeTracker.DetectChanges();
                db.SaveChanges();

            }
        }
Exemplo n.º 10
0
        public AccessModel GetAccessValue(int menuId, int roleId)
        {
            if (roleId == 1002)
            {
                AccessModel model = new AccessModel
                {
                    CanAdd    = true,
                    CanDelete = true,
                    CanEdit   = true,
                    CanView   = true
                };
                return(model);
            }
            else
            {
                using (DB = new practiceEntities())
                {
                    AccessModel model;

                    var accessData = DB.RoleAccesses.FirstOrDefault(a => a.MenuId == menuId && a.RoleId == roleId);

                    if (accessData != null)
                    {
                        model = new AccessModel
                        {
                            CanAdd    = accessData.AllowAdd,
                            CanEdit   = accessData.AllowEdit,
                            CanView   = accessData.AllowView,
                            CanDelete = accessData.AllowDelete
                        };
                    }
                    else
                    {
                        model = new AccessModel
                        {
                            CanAdd    = false,
                            CanDelete = false,
                            CanEdit   = false,
                            CanView   = false
                        };
                    }
                    return(model);
                }
            }
        }
Exemplo n.º 11
0
        public Menu GetMenuById(int menuId)
        {
            try
            {
                using (DB = new practiceEntities())
                {
                    var menu = DB.Menus.FirstOrDefault(x => x.Id == menuId);

                    return(menu);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                return(null);
            }
        }
Exemplo n.º 12
0
        public List <OfficeModel> GetActiveOfficesWithTypes()
        {
            practiceEntities context = new practiceEntities();

            var officeModelList = context.Offices
                                  .Include(x => x.OfficeType)
                                  .OrderBy(x => x.OfficeName)
                                  .Where(x => x.IsActive)
                                  .Select(x => new OfficeModel
            {
                Id             = x.Id,
                OfficeCode     = x.OfficeCode,
                OfficeName     = x.OfficeName,
                OfficeAddress  = x.OfficeAddress,
                OfficeEmail    = x.OfficeEmail,
                OfficePhone    = x.OfficePhone,
                OfficeTypeName = x.OfficeType.OfficeTypeName
            })
                                  .ToList();

            return(officeModelList);
        }
Exemplo n.º 13
0
        public IEnumerable <MissingModel> MissingMatches(MissingModel model)
        {
            var missingModelList = new List <MissingModel>();

            using (var context = new practiceEntities())
            {
                missingModelList = context.spMissingMatches(model.Fname, model.Lname, model.Alias, model.DOB, model.Gender, model.FatherName, model.MotherName)
                                   .Select(x => new MissingModel
                {
                    Id             = x.Id,
                    Fname          = x.Fname,
                    Lname          = x.Lname,
                    Photo          = x.Photo,
                    ComplainByName = x.ComplainByName,
                    ComplainDate   = x.ComplainDate,
                    EnteredDate    = x.EnteredDate,
                    OfficeName     = x.OfficeName
                })
                                   .ToList();
            }
            return(missingModelList);
        }
Exemplo n.º 14
0
        public MissingModel GetOneMissingModel(object id)
        {
            using (practiceEntities db = new practiceEntities())
            {
                MissingModel missingModel = null;
                try
                {
                    var Id = Convert.ToInt32(id);

                    var missing = db.Missings
                                  .Include(x => x.Religion)
                                  .Include(x => x.country)
                                  .Include(x => x.EducationLevel)
                                  .Include(x => x.Colour)
                                  .Include(x => x.Office)
                                  .Include(x => x.IdType)
                                  .Include(x => x.User)
                                  .SingleOrDefault(x => x.Id == Id);

                    missingModel = Mapper.MissingMapper.MissingToMissingModel(missing);

                    if (missing != null)
                    {
                        missingModel.Verifier = unitOfWork.UserRepository
                                                .Get(x => x.UserId == missing.UserId)
                                                .SingleOrDefault()
                                                .Username;

                        missingModel.HairColor = unitOfWork.ColourRepository
                                                 .Get(x => x.id == missing.HairColorId)
                                                 .SingleOrDefault()
                                                 .ColourName;

                        missingModel.EyeColor = unitOfWork.ColourRepository
                                                .Get(x => x.id == missing.EyeColorId)
                                                .SingleOrDefault()
                                                .ColourName;

                        missingModel.PMunicipalityName = unitOfWork.MunicipalityRepository
                                                         .Get(x => x.Id == missing.PMunicipalityId)
                                                         .SingleOrDefault()
                                                         .MunicipalityName;

                        missingModel.TMunicipalityName = unitOfWork.MunicipalityRepository
                                                         .Get(x => x.Id == missing.TMunicipalityId)
                                                         .SingleOrDefault()
                                                         .MunicipalityName;

                        missingModel.MMunicipalityName = unitOfWork.MunicipalityRepository
                                                         .Get(x => x.Id == missing.MMunicipalityId)
                                                         .SingleOrDefault()
                                                         .MunicipalityName;

                        missingModel.PState = unitOfWork.StateRepository
                                              .Get(x => x.StateId == missing.PStateId)
                                              .SingleOrDefault()
                                              .StateName;

                        missingModel.TState = unitOfWork.StateRepository
                                              .Get(x => x.StateId == missing.TStateId)
                                              .SingleOrDefault()
                                              .StateName;

                        missingModel.MState = unitOfWork.StateRepository
                                              .Get(x => x.StateId == missing.MStateId)
                                              .SingleOrDefault()
                                              .StateName;

                        missingModel.TDistrictName = unitOfWork.DistrictRepository
                                                     .Get(x => x.Id == missing.TDistrictId)
                                                     .SingleOrDefault()
                                                     .DistrictNameEng;

                        missingModel.MDistrictName = unitOfWork.DistrictRepository
                                                     .Get(x => x.Id == missing.MDistrictId)
                                                     .SingleOrDefault()
                                                     .DistrictNameEng;

                        missingModel.PDistrictName = unitOfWork.DistrictRepository
                                                     .Get(x => x.Id == missing.PDistrictId)
                                                     .SingleOrDefault()
                                                     .DistrictNameEng;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                return(missingModel);
            }
        }
Exemplo n.º 15
0
 public RepositoryBase()
 {
     context = new practiceEntities();
 }
Exemplo n.º 16
0
        public IEnumerable <MissingExcelReportModel> GetMissingReport(DateTime?startDate, DateTime?endDate, string gender, int?districtId, int?officeId, int?statusId, int?fiscalYearId, string PersonType)
        {
            if (endDate == Convert.ToDateTime("1/1/0001"))
            {
                endDate = DateTime.Now;
            }

            var missingExcelReportModel = new List <MissingExcelReportModel>();

            using (var context = new practiceEntities())
            {
                var missingExcelReporModel = context.Missings
                                             .Include(x => x.Office)
                                             .Where(x => x.VerifyStatus.ToUpper() == "V")
                                             .OrderByDescending(x => x.Id)
                                             .Select(x => new MissingExcelReportModel
                {
                    MissingId          = x.Id,
                    OfficeId           = x.OfficeId,
                    OfficeName         = x.Office.OfficeName,
                    FiscalYearId       = x.FiscalYearId,
                    RegistrationNumber = x.RegistrationNumber.ToString(),
                    FirstName          = x.Fname,
                    LName             = x.Lname,
                    Photo             = x.Photo,
                    Alias             = x.Alias,
                    MatrialStatus     = x.MaritialStatus,
                    EthnicityId       = x.EthnicityId,
                    Gender            = x.Gender,
                    PersonType        = x.PersonType,
                    FatherName        = x.FatherName,
                    MotherName        = x.MotherName,
                    SpouseName        = x.SpouseName,
                    SpecialIdentifier = x.SpecialIdentifier,
                    NationalityId     = x.NationalityId,
                    IdType            = x.IdTypeId,
                    IdTypeNumber      = x.IdTypeNumber,
                    ReligionId        = x.ReligionId,
                    occupation        = x.Occupation,
                    EducationLevelId  = x.EducationLevelId,
                    Dob                    = x.DOB,
                    EstimateAge            = x.EstimatedAge,
                    Height                 = x.Hieght,
                    Weight                 = x.Weight,
                    ClothesWorn            = x.ClothesWorn,
                    EyeColorId             = x.EyeColorId,
                    HairColorId            = x.HairColorId,
                    Build                  = x.Build,
                    TDistrictId            = x.TDistrictId,
                    TMunicipalityId        = x.TMunicipalityId,
                    TToleName              = x.TToleName,
                    TWardNumber            = x.TWardNumber,
                    TContactNumber         = x.TContactNumber,
                    PDistrictId            = x.PDistrictId,
                    PMunicipalityId        = x.PMunicipalityId,
                    PContactNumber         = x.PContactNumber,
                    PToleName              = x.PToleName,
                    PWardNumber            = x.PWardNumber,
                    MDistrictId            = x.MDistrictId,
                    MMunicipalityId        = x.MMunicipalityId,
                    MWardNumber            = x.MWardNumber,
                    MToleName              = x.MToleName,
                    LastSeenDate           = x.LastSeenDate,
                    LastSeenPlace          = x.LastSeenPlace,
                    LastSeenTime           = x.LastSeenTime,
                    EnteredDate            = x.EnteredDate,
                    ComplaintDate          = x.ComplainDate,
                    RelationWithVictim     = x.RelationWithVictim,
                    ComplainName           = x.ComplainByName,
                    ComplainContactNumber  = x.ComplainContactNumber,
                    DateFound              = x.DateOfFound,
                    Remarks                = x.Remarks,
                    PossiblePlaces         = x.PossiblePlaces,
                    MissingReason          = x.MissingReason,
                    MissingStatus          = x.MissingStatus,
                    FoundAddress           = x.FoundAddress,
                    LiveStatus             = x.LiveStatus,
                    FoundRemarks           = x.FoundRemarks,
                    FoundByOfficeId        = x.FoundByOfficeId,
                    HandOverTo             = x.HandOverTo,
                    HandOverDate           = x.HandOverDate,
                    HandOverRelation       = x.HandOverRelation,
                    HandOverDetails        = x.HandOverDetails,
                    HandOverContactNumber  = x.HandOverContactNumber,
                    LastSearchActivityDate = x.LastSearchActivityDate,
                });

                if (startDate != Convert.ToDateTime("1/1/0001"))
                {
                    missingExcelReporModel = missingExcelReporModel.Where(x => x.LastSeenDate >= startDate && x.LastSeenDate <= endDate)
                                             .OrderBy(x => x.LastSeenDate);
                }

                if (!String.IsNullOrEmpty(gender))
                {
                    missingExcelReporModel = missingExcelReporModel.Where(x => x.Gender == gender);
                }

                if (districtId > 0)
                {
                    missingExcelReporModel = missingExcelReporModel.Where(x => x.MDistrictId == districtId);
                }

                if (statusId > 0)
                {
                    missingExcelReporModel = missingExcelReporModel.Where(x => x.MissingStatus == statusId);
                }

                if (fiscalYearId > 0)
                {
                    var fy = context.FiscalYears.SingleOrDefault(x => x.Id == fiscalYearId);

                    missingExcelReporModel = missingExcelReporModel.Where(x => x.LastSeenDate >= fy.StartDate &&
                                                                          x.LastSeenDate <= fy.EndDate);
                }
                if (!String.IsNullOrEmpty(PersonType))
                {
                    missingExcelReporModel = missingExcelReporModel.Where(x => x.PersonType == PersonType);
                }

                var missingExcelReportModelList = missingExcelReporModel.ToList();

                missingExcelReportModel.AddRange(missingExcelReportModelList);

                foreach (var item in missingExcelReportModel)
                {
                    item.TDistrictName = item.TDistrictId != null?
                                         context.Districts.SingleOrDefault(x => x.Id == item.TDistrictId)?.DistrictNameEng : "";

                    item.PDistrictName = item.PDistrictId != null?
                                         context.Districts.SingleOrDefault(x => x.Id == item.PDistrictId)?.DistrictNameEng : "";

                    item.MDistrictname = item.MDistrictId != null?
                                         context.Districts.SingleOrDefault(x => x.Id == item.MDistrictId)?.DistrictNameEng : "";

                    item.TMunicipalityName = item.TMunicipalityId != null?
                                             context.Municipalities.SingleOrDefault(x => x.Id == item.TMunicipalityId)?.MunicipalityName : "";

                    item.PMunicipalityname = item.PMunicipalityId != null?
                                             context.Municipalities.SingleOrDefault(x => x.Id == item.PMunicipalityId)?.MunicipalityName : "";

                    item.MMunicipalityName = item.MMunicipalityId != null?
                                             context.Municipalities.SingleOrDefault(x => x.Id == item.MMunicipalityId)?.MunicipalityName : "";

                    item.IdTypeNumber = item.IdType != null?
                                        context.IdTypes.SingleOrDefault(x => x.id == item.IdType)?.IdTypeName : "";

                    item.NationalityName = item.NationalityId != null?
                                           context.countries.SingleOrDefault(x => x.Id == item.NationalityId)?.CountryName : "N/A";

                    item.ReligionName = item.ReligionId != null?
                                        context.Religions.SingleOrDefault(x => x.Id == item.ReligionId)?.ReligionName : "";

                    item.EducationLevelName = item.EducationLevelId != null?
                                              context.EducationLevels.SingleOrDefault(x => x.Id == item.EducationLevelId)?.LevelName : "";
                }

                return(missingExcelReportModelList);
            }
        }
Exemplo n.º 17
0
        public List <MissingModel> FindMissingRecords(string fname, string lname, DateTime?missingDate, int?missingDistrict, int?missingOffice, int?registrationNumber)
        {
            var missingModelLists = new List <MissingModel>();

            using (var db = new practiceEntities())
            {
                var missingModel = db.Missings
                                   .Include(x => x.User)
                                   .Include(x => x.Office)
                                   .Select(x => new MissingModel
                {
                    Id = x.Id,
                    RegistrationNumber = x.RegistrationNumber,
                    OfficeName         = x.Office.OfficeName,
                    Fname                 = x.Fname,
                    Lname                 = x.Lname,
                    EnteredDate           = x.EnteredDate,
                    Photo                 = x.Photo,
                    LastSeenDate          = x.LastSeenDate,
                    ComplainByName        = x.ComplainByName,
                    ComplainContactNumber = x.ComplainContactNumber,
                    MissingStatus         = x.MissingStatus,
                    OfficeId              = x.OfficeId,
                    MDistrictId           = x.MDistrictId,
                    MMunicipalityId       = x.MMunicipalityId,
                    ComplainDate          = x.ComplainDate,
                    PMunicipalityId       = x.PMunicipalityId,
                    PDistrictId           = x.PDistrictId,
                    PToleName             = x.PToleName,
                    PWardNumber           = x.PWardNumber,
                    MToleName             = x.MToleName,
                    MWardNumber           = x.MWardNumber,
                    MDistrictName         = "",
                    MMunicipalityName     = "",
                    PDistrictName         = "",
                    PMunicipalityName     = ""
                })
                                   .OrderByDescending(x => x.Id)
                                   .Where(x => x.VerifyStatus.ToUpper() == "V" && (x.Fname.Contains(fname) || x.Lname.Contains(lname)));

                if (fname != "")
                {
                    missingModel = missingModel.Where(x => x.Fname.Contains(fname));
                }

                if (lname != "")
                {
                    missingModel = missingModel.Where(x => x.Lname.Contains(lname));
                }

                if (missingDate != Convert.ToDateTime("1/1/0001"))
                {
                    missingModel = missingModel.Where(x => x.ComplainDate == missingDate);
                }

                if (registrationNumber != null)
                {
                    missingModel = missingModel.Where(x => x.RegistrationNumber == registrationNumber);
                }

                if (missingOffice > 0)
                {
                    missingModel = missingModel.Where(x => x.OfficeId == missingOffice);
                }

                if (missingDistrict > 0)
                {
                    missingModel = missingModel.Where(x => x.MDistrictId == missingDistrict);
                }

                var missingModelList = missingModel.ToList();

                missingModelLists.AddRange(missingModelList);

                foreach (var model in missingModelLists)
                {
                    model.PDistrictName = model.PDistrictId != null?db.Districts.SingleOrDefault(x => x.Id == model.PDistrictId)?.DistrictNameEng : "";

                    model.PMunicipalityName = model.PMunicipalityId != null?db.Municipalities.SingleOrDefault(x => x.Id == model.PMunicipalityId)?.MunicipalityName : "";

                    model.MMunicipalityName = model.MMunicipalityId != null?db.Municipalities.SingleOrDefault(x => x.Id == model.MMunicipalityId)?.MunicipalityName : "";

                    model.MDistrictName = model.MDistrictId != null?db.Districts.SingleOrDefault(x => x.Id == model.MDistrictId)?.DistrictNameEng : "";
                }

                return(missingModelList);
            }
        }
Exemplo n.º 18
0
 public FiscalYearService(IUnitOfWork _unitOfWork = null)
 {
     unitOfWork = _unitOfWork ?? new UnitOfWork();
     Db         = new practiceEntities();
 }
Exemplo n.º 19
0
        public MissingService(IUnitOfWork _unitOfWork = null)
        {
            unitOfWork = _unitOfWork ?? new UnitOfWork();

            db = new practiceEntities();
        }
Exemplo n.º 20
0
 public UnitOfWork()
 {
     context = new practiceEntities();
 }
Exemplo n.º 21
0
        public AssignMenuController()
        {
            setupService = new SetupService();

            DB = new practiceEntities();
        }
Exemplo n.º 22
0
 public RepositoryBase(practiceEntities _context)
 {
     context = _context;
     dbSet   = _context.Set <T>();
 }
Exemplo n.º 23
0
 public UnitOfWork(practiceEntities _context)
 {
     context = _context ?? new practiceEntities();
 }
Exemplo n.º 24
0
 public UserService(IUnitOfWork _unitOfWork = null)
 {
     unitOfWork = _unitOfWork ?? new UnitOfWork();
     DB         = new practiceEntities();
 }