|
@@ -593,30 +593,33 @@ namespace UnivateProperties_API.Repository.Properties
|
593
|
593
|
return GetDisplayDetails(props);
|
594
|
594
|
}
|
595
|
595
|
|
596
|
|
- public List<PropertyList> GetPropertyList(string Type, int By)
|
|
596
|
+ public List<PropertyList> GetPropertyList(int By)
|
597
|
597
|
{
|
598
|
|
- var individual = dBContext.Individuals.Where(x => x.UserId == By).FirstOrDefault();
|
599
|
|
- var agent = dBContext.Agents.Where(x => x.UserId == By).FirstOrDefault();
|
600
|
|
-
|
601
|
598
|
List<Property> properties = new List<Property>();
|
602
|
|
- if (Type.ToUpper() == "MY")
|
603
|
|
- {
|
604
|
|
- if (individual != null)
|
605
|
|
- properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.OwnerId == individual.Id).ToList();
|
606
|
|
- if (agent != null)
|
607
|
|
- properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.AgentId == agent.Id).ToList();
|
608
|
|
- }
|
609
|
|
- else if (Type.ToUpper() == "ADMIN")
|
610
|
|
- {
|
611
|
|
- if (individual != null)
|
612
|
|
- properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.OwnerId == individual.Id).ToList();
|
613
|
|
- if (agent != null)
|
614
|
|
- properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.AgencyId == agent.AgencyId).ToList();
|
615
|
|
- }
|
616
|
|
- else if (Type.ToUpper() == "SUPERADMIN")
|
|
599
|
+ var user = dBContext.Users.Where(u => u.Id == By).FirstOrDefault();
|
|
600
|
+ if (user != null)
|
617
|
601
|
{
|
618
|
|
- properties = dBContext.Properties.Include("City").Include("Suburb").ToList();
|
619
|
|
- }
|
|
602
|
+ if (user.Role.ToUpper() == "AGENCY" || user.Role.ToUpper() == "AGENT")
|
|
603
|
+ {
|
|
604
|
+ var agent = dBContext.Agents.Where(a => a.UserId == user.Id).FirstOrDefault();
|
|
605
|
+ if (user.Role.ToUpper() == "AGENCY")
|
|
606
|
+ {
|
|
607
|
+ properties = dBContext.Properties.Where(p => p.AgencyId == agent.AgencyId).ToList();
|
|
608
|
+ }
|
|
609
|
+ else
|
|
610
|
+ {
|
|
611
|
+ properties = dBContext.Properties.Where(p => p.AgentId == agent.Id).ToList();
|
|
612
|
+ }
|
|
613
|
+ }
|
|
614
|
+ if (user.Role.ToUpper() == "PRIVATE USER")
|
|
615
|
+ {
|
|
616
|
+ var individual = dBContext.Individuals.Where(i => i.UserId == user.Id).FirstOrDefault();
|
|
617
|
+
|
|
618
|
+ properties = dBContext.Properties.Where(p => p.OwnerId == individual.Id).ToList();
|
|
619
|
+ }
|
|
620
|
+ if (user.Role.ToUpper() == "SUPER ADMIN")
|
|
621
|
+ properties = dBContext.Properties.Include("City").Include("Suburb").ToList();
|
|
622
|
+ }
|
620
|
623
|
|
621
|
624
|
List<PropertyList> list = new List<PropertyList>();
|
622
|
625
|
|