Пример #1
0
        public IActionResult Cabinet()
        {
            if (_auth.User == null)
            {
                return(RedirectToAction("index", "account"));
            }
            else
            {
                User LoginedUser = _context.Users.Where(u => u.UserId == _auth.User.UserId).FirstOrDefault();

                if (LoginedUser == null)
                {
                    return(BadRequest());
                }
                else
                {
                    ViewBag.AllAddsCount = _context.Addvertisiments.Where(a => a.UserId == _auth.User.UserId && a.AddStatus != AddStatus.Hidden).Count();

                    ViewBag.ActiveAddsCount = _context.Addvertisiments.Where(a => a.UserId == _auth.User.UserId && a.AddStatus == AddStatus.Active).ToList().Count();

                    ViewBag.DeactiveAddsCount = _context.Addvertisiments.Where(a => a.UserId == _auth.User.UserId && a.AddStatus == AddStatus.Deactive).Count();

                    ViewBag.WaitingAddsCount = _context.Addvertisiments.Where(a => a.UserId == _auth.User.UserId && a.AddStatus == AddStatus.Waiting).Count();

                    ViewBag.RentAddsCount = _context.Addvertisiments.Where(a => a.UserId == _auth.User.UserId && a.AddTypeID < 3 && a.AddStatus == AddStatus.Active).Count();

                    ViewBag.SaleAddsCount = _context.Addvertisiments.Where(a => a.UserId == _auth.User.UserId && a.AddTypeID == 3 && a.AddStatus == AddStatus.Active).Count();


                    AccountIndexViewModel data = new AccountIndexViewModel
                    {
                        Cabinet = new AccountCabinetModel
                        {
                            AllAdds = _context.Addvertisiments.Include("User").Include("Property").Include("Property.City").Include("Property.District").Include("Property.PropertySort").Where(a => a.UserId == _auth.User.UserId && a.AddStatus != AddStatus.Hidden).OrderByDescending(a => a.CreatedAt).ToList()
                        },
                        Breadcumb = new BreadcumbViewModel
                        {
                            Title = "Şəxsi kabinet",
                            Path  = new List <BreadcumbItemViewModel>()
                        }
                    };


                    BreadcumbItemViewModel home = new BreadcumbItemViewModel
                    {
                        Name       = "Ana səhifə",
                        Controller = "Home",
                        Action     = "index"
                    };
                    BreadcumbItemViewModel cab = new BreadcumbItemViewModel
                    {
                        Name = "Şəxsi kabinet"
                    };
                    data.Breadcumb.Path.Add(home);
                    data.Breadcumb.Path.Add(cab);
                    ViewBag.Partial = data.Breadcumb;
                    return(View(data));
                }
            }
        }
Пример #2
0
        public IActionResult Signup()
        {
            AccountIndexViewModel data = new AccountIndexViewModel()
            {
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Yeni üzv",
                    Path  = new List <BreadcumbItemViewModel>()
                },
            };

            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel signup = new BreadcumbItemViewModel
            {
                Name = "Qeydiyyat"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(signup);
            ViewBag.Partial   = data.Breadcumb;
            ViewBag.UserTypes = _context.UserTypes.OrderBy(u => u.UserTypeId).ToList();
            return(View());
        }
Пример #3
0
        public IActionResult Index()
        {
            AgencyViewModel data = new AgencyViewModel
            {
                Agencies = new AgencyIndexViewModel
                {
                    Users = _context.Users.Include("Adds").Where(u => u.UserTypeID == 1 && u.Status == UserStatus.Active && u.Adds.Count() > 0).ToList(),
                },
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Agentliklər",
                    Path  = new List <BreadcumbItemViewModel>()
                },
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel Agencies = new BreadcumbItemViewModel
            {
                Name = "Agentliklər"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(Agencies);
            ViewBag.Partial = data.Breadcumb;
            return(View(data));
        }
Пример #4
0
        public IActionResult Index()
        {
            AccountIndexViewModel data = new AccountIndexViewModel()
            {
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Şəxsi kabinetə giriş",
                    Path  = new List <BreadcumbItemViewModel>()
                },
            };

            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel login = new BreadcumbItemViewModel
            {
                Name = "Daxil Ol"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(login);
            ViewBag.Partial = data.Breadcumb;
            return(View());
        }
Пример #5
0
        public IActionResult Settings()
        {
            if (_auth.User == null)
            {
                return(RedirectToAction("index", "account"));
            }

            AccountIndexViewModel data = new AccountIndexViewModel
            {
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Tənzimləmələr",
                    Path  = new List <BreadcumbItemViewModel>()
                },
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel settings = new BreadcumbItemViewModel
            {
                Name = "Tənzimləmələr"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(settings);
            ViewBag.Partial = data.Breadcumb;

            ViewBag.User = _auth.User;
            return(View());
        }
Пример #6
0
        public IActionResult About()
        {
            HomeIndexViewModel data = new HomeIndexViewModel
            {
                About = new AboutIndexViewModel
                {
                    Setting = _context.WebsiteSettings.FirstOrDefault(),
                },
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Haqqımızda",
                    Path  = new List <BreadcumbItemViewModel>()
                }
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel about = new BreadcumbItemViewModel
            {
                Name = "Haqqımızda"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(about);
            ViewBag.Partial = data.Breadcumb;
            return(View(data));
        }
Пример #7
0
        public IActionResult Login(AccountLoginModel Login)
        {
            if (ModelState.IsValid)
            {
                User user = _context.Users.Where(u => u.Email == Login.Email).FirstOrDefault();

                if (user != null)
                {
                    if (Crypto.VerifyHashedPassword(user.Password, Login.Password))
                    {
                        user.Token = Guid.NewGuid().ToString();
                        _context.SaveChanges();

                        Response.Cookies.Append("token", user.Token, new Microsoft.AspNetCore.Http.CookieOptions
                        {
                            Expires  = DateTime.Now.AddYears(1),
                            HttpOnly = true
                        });
                        TempData["Success"] = "Sistemə müvəffəqiyyətlə daxil oldunuz...";
                        return(RedirectToAction("index", "home"));
                    }
                    else
                    {
                        ModelState.AddModelError("Login.Password", "E-poçt və ya şifrə yalnışdır");
                    }
                }
                else
                {
                    ModelState.AddModelError("Login.Password", "E-poçt və ya şifrə yalnışdır");
                }
            }
            AccountIndexViewModel data = new AccountIndexViewModel
            {
                Login = Login
            };

            data.Breadcumb = new BreadcumbViewModel
            {
                Title = "Şəxsi kabinetə giriş",
                Path  = new List <BreadcumbItemViewModel>()
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel login = new BreadcumbItemViewModel
            {
                Name = "Daxil Ol"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(login);
            ViewBag.Partial = data.Breadcumb;
            return(View("~/Views/Account/Index.cshtml"));
        }
Пример #8
0
        public IActionResult Index()
        {
            AddViewModel data = new AddViewModel
            {
                FilterPanel = new FilterPanelViewModel
                {
                    AddTypes      = _context.AddTypes.ToList(),
                    Cities        = _context.Cities.ToList(),
                    PropertySorts = _context.PropertySorts.ToList(),
                },
                AddsPanel = new AddsPanelViewModel
                {
                    Type    = ViewType.small,
                    AddList = _context.Addvertisiments.Include("AddType").
                              Include("Property").
                              Include("Property.City").
                              Include("Property.District").
                              Include("Property.Flat").
                              Include("Property.Floor").
                              Include("Property.PropDoc").
                              Include("Property.PropertySort").
                              Include("Property.Project").
                              Where(a => a.User.Status == UserStatus.Active && a.AddStatus == AddStatus.Active).OrderByDescending(a => a.CreatedAt).ToList(),
                },
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Elanlar",
                    Path  = new List <BreadcumbItemViewModel>()
                },
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };

            BreadcumbItemViewModel adds = new BreadcumbItemViewModel
            {
                Name = "Bütün elanlar"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(adds);

            ViewBag.Partial   = data.Breadcumb;
            ViewBag.Filters   = data.FilterPanel;
            ViewBag.Adds      = data.AddsPanel;
            ViewBag.AddsCount = data.AddsPanel.AddList.Count();
            return(View(data));
        }
Пример #9
0
        public IActionResult Create()
        {
            if (_auth.User == null)
            {
                return(RedirectToAction("index", "account"));
            }
            else
            {
                AddViewModel data = new AddViewModel
                {
                    AddCreateIndex = new AddCreateIndexViewModel {
                        Cities        = _context.Cities.Include(c => c.Districts).ToList(),
                        PropertySorts = _context.PropertySorts.OrderBy(ps => ps.PropertySortId).ToList(),
                        AddTypes      = _context.AddTypes.OrderBy(ad => ad.AddTypeId).ToList(),
                        Flats         = _context.Flats.OrderBy(f => f.FlatID).ToList(),
                        Floors        = _context.Floors.OrderBy(f => f.FloorID).ToList(),
                        PropDocs      = _context.PropDocs.OrderBy(ps => ps.PropDocID).ToList(),
                        Features      = _context.Features.OrderBy(f => f.FeatureID).ToList()
                    },

                    Breadcumb = new BreadcumbViewModel

                    {
                        Title = "Elan yerləşdir",
                        Path  = new List <BreadcumbItemViewModel>()
                    },
                };
                BreadcumbItemViewModel home = new BreadcumbItemViewModel
                {
                    Name       = "Ana səhifə",
                    Controller = "Home",
                    Action     = "index"
                };

                BreadcumbItemViewModel create = new BreadcumbItemViewModel
                {
                    Name = "Elan yerləşdirmə"
                };

                data.Breadcumb.Path.Add(home);
                data.Breadcumb.Path.Add(create);

                ViewBag.Partial = data.Breadcumb;


                return(View(data));
            }
        }
Пример #10
0
        public IActionResult Settings(AccountSettingModel setting)
        {
            var token = Request.Cookies["token"];

            User LoggedUser = _auth.User;

            if (LoggedUser.Token != token)
            {
                return(BadRequest());
            }

            string FileName;

            if (ModelState.IsValid)
            {
                LoggedUser.Name        = setting.Name;
                LoggedUser.PhoneNumber = setting.PhoneNumber;


                if (LoggedUser.UserTypeID > 1) // if user type is ev sahibi or makler
                {
                    LoggedUser.Surname = setting.Surname;
                }

                if (LoggedUser.UserTypeID == 1) //if usertype is Agentlik
                {
                    LoggedUser.Adress       = setting.Adress;
                    LoggedUser.AboutCompany = setting.AboutCompany;
                }

                FileStream fs = null;

                if (setting.Photo != null)
                {
                    string UploadsFolder = Path.Combine(_hosting.WebRootPath, "img", "users");
                    FileName = Guid.NewGuid() + "_" + setting.Photo.FileName;
                    string FilePath = Path.Combine(UploadsFolder, FileName);
                    fs = new FileStream(FilePath, FileMode.OpenOrCreate);
                    setting.Photo.CopyTo(fs);
                    LoggedUser.Logo = FileName;

                    fs.Close();
                }



                _context.Entry(LoggedUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.SaveChanges();
                TempData["Success"] = "Məlumatlar müvəffəqiyyətlə daxil etdiniz...";
                return(RedirectToAction("index", "home"));
            }

            AccountIndexViewModel data = new AccountIndexViewModel
            {
                Setting   = setting,
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Tənzimləmələr",
                    Path  = new List <BreadcumbItemViewModel>()
                }
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel settings = new BreadcumbItemViewModel
            {
                Name = "Tənzimləmələr"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(settings);

            ViewBag.Partial = data.Breadcumb;

            return(View("~/Views/Account/Profile.cshtml"));
        }
Пример #11
0
        public IActionResult Register(AccountRegisterModel register)
        {
            if (ModelState.IsValid)
            {
                if (!_context.Users.Any(u => u.Email == register.Email))
                {
                    User NewUser = new User
                    {
                        Name        = register.Name,
                        Email       = register.Email,
                        Password    = Crypto.HashPassword(register.Password),
                        Token       = Guid.NewGuid().ToString(),
                        UserTypeID  = register.UserTypeId,
                        PhoneNumber = register.PhoneNumber,
                        CreatedAt   = DateTime.Now,
                        Status      = UserStatus.Waiting,
                    };


                    if (register.UserTypeId > 1)
                    {
                        NewUser.Surname = register.Surname;
                    }

                    _context.Users.Add(NewUser);
                    _context.SaveChanges();

                    Response.Cookies.Append("token", NewUser.Token, new Microsoft.AspNetCore.Http.CookieOptions
                    {
                        Expires  = DateTime.Now.AddYears(1),
                        HttpOnly = true
                    });
                    return(RedirectToAction("settings", "account"));
                }
                else
                {
                    ModelState.AddModelError("Register.Email", "E-Poçt ünvanı artıq registrasiyadan keçib");
                }
            }

            AccountIndexViewModel data = new AccountIndexViewModel
            {
                Register = register
            };

            data.Breadcumb = new BreadcumbViewModel
            {
                Title = "Yeni üzv",
                Path  = new List <BreadcumbItemViewModel>()
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };
            BreadcumbItemViewModel signup = new BreadcumbItemViewModel
            {
                Name = "Qeydiyyat"
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(signup);
            ViewBag.Partial   = data.Breadcumb;
            ViewBag.UserTypes = _context.UserTypes.OrderBy(u => u.UserTypeId).ToList();
            return(View("~/Views/Account/Signup.cshtml"));
        }
Пример #12
0
        public IActionResult Sale(int id)
        {
            PropertySort propertySort = _context.PropertySorts.Where(ps => ps.PropertySortId == id).FirstOrDefault();

            if (propertySort != null)
            {
                AddViewModel data = new AddViewModel
                {
                    FilterPanel = new FilterPanelViewModel
                    {
                        AddTypes      = _context.AddTypes.ToList(),
                        Cities        = _context.Cities.ToList(),
                        PropertySorts = _context.PropertySorts.ToList(),
                    },
                    AddsPanel = new AddsPanelViewModel
                    {
                        Type    = ViewType.small,
                        AddList = _context.Addvertisiments.Include("AddType").
                                  Include("Property").
                                  Include("Property.City").
                                  Include("Property.District").
                                  Include("Property.Flat").
                                  Include("Property.Floor").
                                  Include("Property.PropDoc").
                                  Include("Property.PropertySort").
                                  Include("Property.Project").
                                  Where(a => a.AddTypeID > 2 && a.User.Status == UserStatus.Active && a.AddStatus == AddStatus.Active && a.Property.PropertySortId == id).OrderByDescending(a => a.CreatedAt).ToList(),
                    },
                    Breadcumb = new BreadcumbViewModel
                    {
                        Title = "Satış elanları",
                        Path  = new List <BreadcumbItemViewModel>()
                    },
                };
                BreadcumbItemViewModel home = new BreadcumbItemViewModel
                {
                    Name       = "Ana səhifə",
                    Controller = "Home",
                    Action     = "index"
                };

                BreadcumbItemViewModel adds = new BreadcumbItemViewModel
                {
                    Name       = "Bütün elanlar",
                    Controller = "Add",
                    Action     = "index"
                };
                BreadcumbItemViewModel finded = new BreadcumbItemViewModel
                {
                    Name = propertySort.PropertySortName,
                };

                data.Breadcumb.Path.Add(home);
                data.Breadcumb.Path.Add(adds);
                data.Breadcumb.Path.Add(finded);
                ViewBag.Partial   = data.Breadcumb;
                ViewBag.Filters   = data.FilterPanel;
                ViewBag.Adds      = data.AddsPanel;
                ViewBag.AddsCount = data.AddsPanel.AddList.Count();
                return(View(data));
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #13
0
        public IActionResult Detail(int id)
        {
            Addvertisiment Add = _context.Addvertisiments.Include("AddType").
                                 Include("Property").
                                 Include("Property.City").
                                 Include("Property.District").
                                 Include("Property.Flat").
                                 Include("Property.Floor").
                                 Include("Property.PropDoc").
                                 Include("Property.PropertySort").
                                 Include("Property.Project").
                                 Where(a => a.AddvertisimentID == id).FirstOrDefault();

            if (Add == null || ((Add.AddStatus == AddStatus.Deactive || Add.AddStatus == AddStatus.Hidden || Add.AddStatus == AddStatus.Waiting) && _auth.APuser == null)) //Dont show Hidden, Waiting, Deactive adds to Users or Quests
            {
                return(NotFound());
            }
            else
            {
                AddViewModel data = new AddViewModel
                {
                    AddDetailIndex = new AddDetailIndexViewModel
                    {
                        Add            = Add,
                        PropertyPhotos = _context.PropPhotos.Where(pp => pp.PropertyId == Add.PropertyID).ToList(),
                        Features       = _context.PropFeatures.Include(pf => pf.Feature).Where(pf => pf.PropertyID == Add.PropertyID).ToList(),
                    },
                    Owner = new OwnerPanelViewModel
                    {
                        Owner           = _context.Users.Include(u => u.Adds).Where(u => u.UserId == Add.UserId).FirstOrDefault(),
                        OwnerActiveAdds = _context.Addvertisiments.Where(a => a.UserId == Add.UserId && a.AddStatus == AddStatus.Active).Count()
                    },
                    AddsPanel = new AddsPanelViewModel
                    {
                        Type    = ViewType.normal,
                        AddList = _context.Addvertisiments.Include("Property").
                                  Include("Property.City").
                                  Include("Property.District").
                                  Include("Property.Flat").
                                  Include("Property.Floor").
                                  Include("Property.PropDoc").
                                  Include("Property.PropertySort").
                                  Include("Property.Project").
                                  Where(a => a.User.Status == UserStatus.Active && a.AddStatus == AddStatus.Active && a.AddTypeID == Add.AddTypeID && a.Property.PropertySortId == Add.Property.PropertySortId && a.AddvertisimentID != Add.AddvertisimentID).
                                  OrderByDescending(a => a.CreatedAt).Take(8).ToList(),
                    },
                    Breadcumb = new BreadcumbViewModel
                    {
                        Title = "Elan haqqında",
                        Path  = new List <BreadcumbItemViewModel>()
                    }
                };

                BreadcumbItemViewModel home = new BreadcumbItemViewModel
                {
                    Name       = "Ana səhifə",
                    Controller = "Home",
                    Action     = "index"
                };

                BreadcumbItemViewModel adds = new BreadcumbItemViewModel
                {
                    Name       = "Bütün elanlar",
                    Controller = "Add",
                    Action     = "index"
                };

                BreadcumbItemViewModel detail = new BreadcumbItemViewModel
                {
                    Name = "Elan haqqında"
                };

                data.Breadcumb.Path.Add(home);
                data.Breadcumb.Path.Add(adds);
                data.Breadcumb.Path.Add(detail);
                ViewBag.Partial = data.Breadcumb;
                ViewBag.Adds    = data.AddsPanel;
                ViewBag.Owner   = data.Owner;
                return(View(data));
            }
        }
Пример #14
0
        public IActionResult Create(AddCreatePostViewModel AddCreatePost)
        {
            //Checking User who created addvertisiment
            if (_auth.User.Token != Request.Cookies["token"])
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                Property newProp = new Property //CREATE NEW PROPERTY
                {
                    CityId         = AddCreatePost.CityId,
                    DistrictId     = AddCreatePost.DistrictId,
                    PropertySortId = AddCreatePost.PropertySortId,
                    PropDocId      = AddCreatePost.PropDocId,
                    FloorId        = AddCreatePost.FloorId,
                    FloorSum       = AddCreatePost.FloorSum,
                    FlatId         = AddCreatePost.FlatId,
                    PropProjectId  = AddCreatePost.ProjectId,
                    BuildingVolume = AddCreatePost.BuildingVolume,
                    LandVolume     = AddCreatePost.LandVolume,
                    Longitude      = AddCreatePost.Longitude,
                    Latitude       = AddCreatePost.Latitude,
                    FullAbout      = AddCreatePost.FullAbout,
                    FullAddress    = AddCreatePost.PropertyFullAddress
                };


                _context.Properties.Add(newProp);
                _context.SaveChanges();

                foreach (Feature item in AddCreatePost.Features)
                {
                    if (item.Selected)
                    {
                        PropFeature newPropFeature = new PropFeature //PROPERTY FEATURE
                        {
                            PropertyID = newProp.PropertyId,
                            FeatureID  = item.FeatureID
                        };

                        _context.PropFeatures.Add(newPropFeature);
                        _context.SaveChanges();
                    }
                }

                string FileName;

                if (AddCreatePost.Photos != null && AddCreatePost.Photos.Count() > 0)
                {
                    foreach (IFormFile photo in AddCreatePost.Photos)
                    {
                        string UploadsFolder;

                        UploadsFolder = Path.Combine(_hosting.WebRootPath, "img", "property");

                        FileName = Guid.NewGuid() + "_" + photo.FileName;
                        string FilePath = Path.Combine(UploadsFolder, FileName);

                        FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate);

                        photo.CopyTo(fs);

                        fs.Close();


                        PropPhoto newPropPhoto = new PropPhoto //CREATE NEW PHOTO OF PROPERTY
                        {
                            PropPhotoName = FileName,
                            PropertyId    = newProp.PropertyId
                        };
                        _context.PropPhotos.Add(newPropPhoto);
                        _context.SaveChanges();
                    }
                }

                Addvertisiment newAdd = new Addvertisiment // CREATE NEW ADDVERTISIMENT
                {
                    PropertyID = newProp.PropertyId,
                    UserId     = _auth.User.UserId,
                    AddTypeID  = AddCreatePost.AddTypeId,
                    PropPrice  = AddCreatePost.AddPrice,
                    CreatedAt  = DateTime.Now,
                    ExpDate    = DateTime.Now.AddMonths(1),
                    AddStatus  = AddStatus.Waiting
                };

                _context.Addvertisiments.Add(newAdd);

                newProp.MainPhoto             = newProp.Photos[0].PropPhotoName;
                _context.Entry(newProp).State = Microsoft.EntityFrameworkCore.EntityState.Modified;

                _context.SaveChanges();

                TempData["Success"] = "Elanınız qəbul edildi, təsdiq edildikdən sonra yayımlanacaq.";

                return(RedirectToAction("cabinet", "account"));
            }
            else
            {
                AddViewModel data = new AddViewModel
                {
                    AddCreateIndex = new AddCreateIndexViewModel
                    {
                        Cities        = _context.Cities.Include(c => c.Districts).ToList(),
                        PropertySorts = _context.PropertySorts.OrderBy(ps => ps.PropertySortId).ToList(),
                        AddTypes      = _context.AddTypes.OrderBy(ad => ad.AddTypeId).ToList(),
                        Flats         = _context.Flats.OrderBy(f => f.FlatID).ToList(),
                        Floors        = _context.Floors.OrderBy(f => f.FloorID).ToList(),
                        PropDocs      = _context.PropDocs.OrderBy(ps => ps.PropDocID).ToList(),
                        Features      = _context.Features.OrderBy(f => f.FeatureID).ToList()
                    },

                    Breadcumb = new BreadcumbViewModel

                    {
                        Title = "Elan yerləşdir",
                        Path  = new List <BreadcumbItemViewModel>()
                    },
                };
                BreadcumbItemViewModel home = new BreadcumbItemViewModel
                {
                    Name       = "Ana səhifə",
                    Controller = "Home",
                    Action     = "index"
                };

                BreadcumbItemViewModel create = new BreadcumbItemViewModel
                {
                    Name = "Elan yerləşdirmə"
                };

                data.Breadcumb.Path.Add(home);
                data.Breadcumb.Path.Add(create);

                ViewBag.Partial = data.Breadcumb;


                return(View(data));
            }
        }
Пример #15
0
        public IActionResult Search(AddSearchGetViewModel SearchGet)
        {
            if (ModelState.IsValid)
            {
                AddViewModel data = new AddViewModel
                {
                    FilterPanel = new FilterPanelViewModel
                    {
                        AddTypes      = _context.AddTypes.ToList(),
                        Cities        = _context.Cities.ToList(),
                        PropertySorts = _context.PropertySorts.ToList(),
                    },
                    AddsPanel = new AddsPanelViewModel
                    {
                        Type    = ViewType.small,
                        AddList = _context.Addvertisiments.Include("AddType").
                                  Include("Property").
                                  Include("Property.City").
                                  Include("Property.District").
                                  Include("Property.Flat").
                                  Include("Property.Floor").
                                  Include("Property.PropDoc").
                                  Include("Property.PropertySort").
                                  Include("Property.Project").
                                  Where(a => a.User.Status == UserStatus.Active &&
                                        a.AddStatus == AddStatus.Active &&
                                        ((SearchGet.AddTypeId == null ? true : a.AddTypeID == SearchGet.AddTypeId) &&
                                         (SearchGet.CityId == null ? true : a.Property.CityId == SearchGet.CityId) &&
                                         (SearchGet.DistrictId == null ? true : a.Property.DistrictId == SearchGet.DistrictId) &&
                                         (SearchGet.PropertySortId == null ? true : a.Property.PropertySortId == SearchGet.PropertySortId))).OrderByDescending(a => a.CreatedAt).ToList(),
                    },
                    Breadcumb = new BreadcumbViewModel
                    {
                        Title = "Axtarılan elanlar",
                        Path  = new List <BreadcumbItemViewModel>()
                    },
                };
                BreadcumbItemViewModel home = new BreadcumbItemViewModel
                {
                    Name       = "Ana səhifə",
                    Controller = "Home",
                    Action     = "index"
                };

                BreadcumbItemViewModel adds = new BreadcumbItemViewModel
                {
                    Name       = "Bütün elanlar",
                    Controller = "Add",
                    Action     = "index"
                };
                BreadcumbItemViewModel finded = new BreadcumbItemViewModel
                {
                    Name = "Axtarış"
                };
                data.Breadcumb.Path.Add(home);
                data.Breadcumb.Path.Add(adds);
                data.Breadcumb.Path.Add(finded);
                ViewBag.Partial   = data.Breadcumb;
                ViewBag.Filters   = data.FilterPanel;
                ViewBag.Adds      = data.AddsPanel;
                ViewBag.AddsCount = data.AddsPanel.AddList.Count();
                return(View(data));
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #16
0
        public IActionResult Detail(int id)
        {
            User selectedUser = _context.Users.Include("Adds").Where(u => u.UserId == id).FirstOrDefault();

            if (selectedUser == null || selectedUser.UserTypeID > 1 && _auth.APuser == null) //Dont show Owners and Mediators to Users and Quests
            {
                return(NotFound());
            }

            AgencyViewModel data = new AgencyViewModel
            {
                Owner = new OwnerPanelViewModel
                {
                    Owner           = selectedUser,
                    OwnerActiveAdds = _context.Addvertisiments.Where(a => a.UserId == id && a.AddStatus == AddStatus.Active).Count()
                },
                Breadcumb = new BreadcumbViewModel
                {
                    Title = "Agentliyin elanları",
                    Path  = new List <BreadcumbItemViewModel>()
                },
                AddsPanel = new AddsPanelViewModel
                {
                    Type    = ViewType.small,
                    AddList = _context.Addvertisiments.Include("Property").
                              Include("Property.City").
                              Include("Property.District").
                              Include("Property.Flat").
                              Include("Property.Floor").
                              Include("Property.PropDoc").
                              Include("Property.PropertySort").
                              Include("Property.Project").
                              Where(a => a.UserId == id && a.AddStatus == AddStatus.Active).
                              OrderByDescending(a => a.CreatedAt).ToList(),
                }
            };
            BreadcumbItemViewModel home = new BreadcumbItemViewModel
            {
                Name       = "Ana səhifə",
                Controller = "Home",
                Action     = "index"
            };

            BreadcumbItemViewModel Agencies = new BreadcumbItemViewModel
            {
                Name       = "Agentliklər",
                Controller = "Agency",
                Action     = "index"
            };

            BreadcumbItemViewModel AgencyDetail = new BreadcumbItemViewModel {
                Name = selectedUser.Name,
            };

            data.Breadcumb.Path.Add(home);
            data.Breadcumb.Path.Add(Agencies);
            data.Breadcumb.Path.Add(AgencyDetail);
            ViewBag.Partial   = data.Breadcumb;
            ViewBag.Owner     = data.Owner;
            ViewBag.Adds      = data.AddsPanel;
            ViewBag.AddsCount = data.AddsPanel.AddList.Count();
            return(View());
        }