예제 #1
0
        public static List <BusinessObjects.User> GetAllByDistrict(int DistrictId)
        {
            List <BusinessObjects.User> list = new List <BusinessObjects.User>();

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var Users = context.Users.Include(u => u.District).Where(u => u.DistrictId == DistrictId).ToList();
                foreach (var user in Users)
                {
                    BusinessObjects.User UserBO = new BusinessObjects.User
                    {
                        Name        = user.Name,
                        PhoneNumber = user.PhoneNumber,
                        EmailId     = user.EmailId,
                        Id          = user.Id,
                        DistrictId  = user.DistrictId
                    };
                    //Adding Foreign Keys
                    //District
                    UserBO.District = new BusinessObjects.District
                    {
                        Id   = user.District.Id,
                        Name = user.District.Name
                    };

                    list.Add(UserBO);
                    context.Dispose();
                }
            }
            return(list);
        }
예제 #2
0
        public static bool Update(BusinessObjects.Job jobBO)
        {
            int i = 0;

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var InDb = context.Jobs.SingleOrDefault(j => j.Id == jobBO.Id);
                InDb.IsPathStored    = jobBO.IsPathStored;
                InDb.IsVerified      = jobBO.IsVerified;
                InDb.SchemaId        = jobBO.SchemaId;
                InDb.StartLatitude   = jobBO.StartLatitude;
                InDb.StartLongitude  = jobBO.StartLongitude;
                InDb.EstimatedBudget = jobBO.EstimatedBudget;
                InDb.EndLatitude     = jobBO.EndLatitude;
                InDb.EndLongitude    = jobBO.EndLongitude;
                InDb.PreviousGrant   = jobBO.PreviousGrant;
                InDb.VillageId       = jobBO.VillageId;
                InDb.WorkNameId      = jobBO.WorkNameId;
                i = context.SaveChanges();
                context.Dispose();
            }

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        public static bool Add(BusinessObjects.User userBO)
        {
            int i    = 0;
            var user = new User
            {
                Name        = userBO.Name,
                PhoneNumber = userBO.PhoneNumber,
                EmailId     = userBO.EmailId,
                DistrictId  = userBO.DistrictId
            };

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                context.Users.Add(user);
                i = context.SaveChanges();
                context.Dispose();
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
 public static BusinessObjects.Job GetDetails(Guid Id)
 {
     BusinessObjects.Job job = null;
     using (ADOBathindaEntities context = new ADOBathindaEntities())
     {
         var InDb = context.Jobs.SingleOrDefault(j => j.Id == Id);
         job = new BusinessObjects.Job
         {
             Id              = InDb.Id,
             DateAdded       = InDb.DateAdded,
             EndLatitude     = InDb.EndLatitude,
             EndLongitude    = InDb.EndLongitude,
             EstimatedBudget = InDb.EstimatedBudget,
             IsPathStored    = InDb.IsPathStored,
             IsVerified      = InDb.IsVerified,
             PreviousGrant   = InDb.PreviousGrant,
             SchemaId        = InDb.SchemaId,
             StartLatitude   = InDb.StartLatitude,
             StartLongitude  = InDb.StartLongitude,
             VillageId       = InDb.VillageId,
             WorkNameId      = InDb.WorkNameId
         };
     }
     return(job);
 }
예제 #5
0
        public static List <BusinessObjects.Job> GetAllAssignedJobs()
        {
            List <BusinessObjects.Job> list = new List <BusinessObjects.Job>();

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var JobsInDb = context.Jobs.Where(j => j.IsVerified == false).ToList();
                foreach (var InDb in JobsInDb)
                {
                    BusinessObjects.Job job = new BusinessObjects.Job
                    {
                        Id              = InDb.Id,
                        DateAdded       = InDb.DateAdded,
                        EndLatitude     = InDb.EndLatitude,
                        EndLongitude    = InDb.EndLongitude,
                        EstimatedBudget = InDb.EstimatedBudget,
                        IsPathStored    = InDb.IsPathStored,
                        IsVerified      = InDb.IsVerified,
                        PreviousGrant   = InDb.PreviousGrant,
                        SchemaId        = InDb.SchemaId,
                        StartLatitude   = InDb.StartLatitude,
                        StartLongitude  = InDb.StartLongitude,
                        VillageId       = InDb.VillageId,
                        WorkNameId      = InDb.WorkNameId
                    };

                    list.Add(job);
                }
            }
            return(list);
        }
예제 #6
0
        public static bool Add(BusinessObjects.Job jobBO)
        {
            int i   = 0;
            var job = new Job
            {
                DateAdded       = DateTime.Now,
                Id              = Guid.NewGuid(),
                EstimatedBudget = jobBO.EstimatedBudget,
                IsPathStored    = false,
                IsVerified      = false,
                SchemaId        = jobBO.SchemaId,
                VillageId       = jobBO.VillageId,
                WorkNameId      = jobBO.WorkNameId
            };

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                context.Jobs.Add(job);
                i = context.SaveChanges();
                context.Dispose();
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #7
0
        public static BusinessObjects.User GetDetails(int Id)
        {
            BusinessObjects.User userBO = null;
            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var InDb = context.Users.Include(u => u.District).SingleOrDefault(u => u.Id == Id);
                userBO = new BusinessObjects.User
                {
                    Name        = InDb.Name,
                    PhoneNumber = InDb.PhoneNumber,
                    EmailId     = InDb.EmailId,
                    Id          = InDb.Id,
                    DistrictId  = InDb.DistrictId
                };
                //Adding Foreign Keys
                //District
                userBO.District = new BusinessObjects.District
                {
                    Id   = InDb.District.Id,
                    Name = InDb.District.Name
                };

                context.Dispose();
            }
            return(userBO);
        }
예제 #8
0
 public static BusinessObjects.WorkName GetDetails(int Id)
 {
     BusinessObjects.WorkName workName = null;
     using (ADOBathindaEntities context = new ADOBathindaEntities())
     {
         var InDb = context.WorkNames.SingleOrDefault(w => w.Id == Id);
         workName = new BusinessObjects.WorkName
         {
             Id   = InDb.Id,
             Name = InDb.Name
         };
         context.Dispose();
     }
     return(workName);
 }
예제 #9
0
        public static List <BusinessObjects.WorkName> GetAll()
        {
            List <BusinessObjects.WorkName> list = new List <BusinessObjects.WorkName>();

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var WorkNames = context.WorkNames.ToList();
                foreach (var InDb in WorkNames)
                {
                    BusinessObjects.WorkName workName = new BusinessObjects.WorkName
                    {
                        Id   = InDb.Id,
                        Name = InDb.Name
                    };
                    list.Add(workName);
                }
            }
            return(list);
        }
예제 #10
0
        public static bool Delete(BusinessObjects.User userBO)
        {
            int i = 0;

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var InDb = context.Users.SingleOrDefault(u => u.Id == userBO.Id);
                context.Users.Remove(InDb);
                i = context.SaveChanges();
                context.Dispose();
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #11
0
        public static bool Delete(BusinessObjects.Job jobBO)
        {
            int i = 0;

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var InDb = context.Jobs.SingleOrDefault(j => j.Id == jobBO.Id);
                context.Jobs.Remove(InDb);
                i = context.SaveChanges();
            }

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #12
0
        public static bool Delete(BusinessObjects.WorkName workNameBO)
        {
            int i = 0;

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var InDb = context.WorkNames.SingleOrDefault(w => w.Id == workNameBO.Id);
                context.WorkNames.Remove(InDb);
                i = context.SaveChanges();
                context.Dispose();
            }
            if (i < 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #13
0
        public static bool Update(BusinessObjects.User userBO)
        {
            int i = 0;

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                var InDb = context.Users.SingleOrDefault(u => u.Id == userBO.Id);
                InDb.Name        = userBO.Name;
                InDb.PhoneNumber = userBO.PhoneNumber;
                InDb.EmailId     = userBO.EmailId;
                InDb.DistrictId  = userBO.DistrictId;
                i = context.SaveChanges();
                context.Dispose();
            }
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #14
0
        public static bool Add(BusinessObjects.WorkName workNameBO)
        {
            int i        = 0;
            var workName = new WorkName
            {
                Name = workNameBO.Name
            };

            using (ADOBathindaEntities context = new ADOBathindaEntities())
            {
                context.WorkNames.Add(workName);
                i = context.SaveChanges();
                context.Dispose();
            }

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #15
0
 public VillageDA()
 {
     context = new ADOBathindaEntities();
 }
예제 #16
0
 public GrantDA()
 {
     context = new ADOBathindaEntities();
 }
예제 #17
0
 public SchemaDA()
 {
     context = new ADOBathindaEntities();
 }
예제 #18
0
 public DistrictDA()
 {
     context = new ADOBathindaEntities();
 }