Пример #1
0
        public IActionResult Edit(APAccountEditModel Edit)
        {
            APuser SelectedUser = _context.APusers.Where(apu => apu.Email == Edit.Email).FirstOrDefault();

            if (ModelState.IsValid)
            {
                SelectedUser.isAdmin  = Edit.isAdmin;
                SelectedUser.Nickname = Edit.Name;
                SelectedUser.Password = Crypto.HashPassword(Edit.Password);
                SelectedUser.Token    = null;



                _context.Entry(SelectedUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.SaveChanges();

                return(RedirectToAction("APUsers", "Account"));
            }

            APAccountIndexViewModel data = new APAccountIndexViewModel
            {
                SelectedUser = SelectedUser
            };

            return(View("~/Areas/Admin/Views/Account/Edit.cshtml", data));
        }
Пример #2
0
        public IActionResult Editsettings(APSettingEditModel settingEdit)
        {
            string FileName;

            WebsiteSetting Selected = _context.WebsiteSettings.FirstOrDefault();

            if (ModelState.IsValid)
            {
                Selected.LocalAddress    = settingEdit.LocalAddress;
                Selected.PhoneNumber     = settingEdit.PhoneNumber;
                Selected.MobileNumber    = settingEdit.PhoneNumber;
                Selected.Email           = settingEdit.Email;
                Selected.FacebookAddress = settingEdit.FacebookAddress;
                Selected.LinkedinAddress = settingEdit.LinkedinAddress;
                Selected.TwitterAdress   = settingEdit.TwitterAdress;

                if (settingEdit.Logo1 != null)
                {
                    string UploadsFolder = Path.Combine(_hosting.WebRootPath, "img", "logo");
                    FileName = Guid.NewGuid() + "_" + settingEdit.Logo1.FileName;
                    string FilePath = Path.Combine(UploadsFolder, FileName);
                    settingEdit.Logo1.CopyTo(new FileStream(FilePath, FileMode.Create));
                    Selected.MainLogo = FileName;
                }

                if (settingEdit.Logo2 != null)
                {
                    string UploadsFolder = Path.Combine(_hosting.WebRootPath, "img", "logo");
                    FileName = Guid.NewGuid() + "_" + settingEdit.Logo2.FileName;
                    string FilePath = Path.Combine(UploadsFolder, FileName);
                    settingEdit.Logo2.CopyTo(new FileStream(FilePath, FileMode.Create));
                    Selected.FooterLogo = FileName;
                }

                if (settingEdit.About != null)
                {
                    Selected.About = settingEdit.About;
                }

                _context.Entry(Selected).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.SaveChanges();

                return(RedirectToAction("Settings", "Home"));
            }

            APHomeIndexViewModel data = new APHomeIndexViewModel
            {
                setting = Selected
            };

            return(View("~/Areas/Admin/Views/Home/Editsettings.cshtml", data));
        }
Пример #3
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"));
        }
Пример #4
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));
            }
        }