Esempio n. 1
0
        // GET: Admin/Advertisements
        public async Task <IActionResult> Index()
        {
            List <AdvertisementModel> model = new List <AdvertisementModel>();
            List <Advertisement>      query = await _context.Advertisements.ToListAsync();

            foreach (Advertisement item in query)
            {
                AdvertisementModel adv = new AdvertisementModel
                {
                    CodeFlash  = item.CodeFlash,
                    CreateDate = item.CreateDate,
                    EndDate    = item.EndDate,
                    FlashCode  = item.FlashCode,
                    IsApproved = item.IsApproved,
                    PictureId  = item.PictureId,
                    StartDate  = item.StartDate,
                    TargetId   = item.TargetId,
                    UrlAddress = item.UrlAddress,
                    Id         = item.Id,
                    SectionId  = item.SectionId
                };
                if (query.Count > 0)
                {
                    adv.PictureUrl = adv.PictureId == 0 ? _pictureService.GetDefaultPictureUrl(100) : _pictureService.GetPictureUrl(_pictureService.GetPictureById(item.PictureId), 100);
                }

                PrepareCompanyList(adv.AvailableSections, true, "Reklemın Çıkacağı yeri Seçiniz");
                model.Add(adv);
            }
            return(View(model));
        }
        public async Task <IActionResult> postad(AdvertisementModel model)
        {
            if (ModelState.IsValid)
            {
                model.Userid = _userService.GetUserId();
                if (model.GalleryFiles != null)
                {
                    string folder = "advertisement/gallery/";

                    model.Gallery = new List <GalleryModel>();

                    foreach (var file in model.GalleryFiles)
                    {
                        var gallery = new GalleryModel()
                        {
                            Name = file.FileName,
                            URL  = await UploadImage(folder, file),
                        };
                        model.Gallery.Add(gallery);
                    }
                }
                var id = await _advertisementRepository.AddNewAdvertisement(model);

                if (id > 0)
                {
                    return(RedirectToAction(nameof(managead), new { UserId = 0 }));
                }
            }


            return(View());
        }
Esempio n. 3
0
        public async Task <HttpResponseMessage> DeleteAsync(AdvertisementModel _param)
        {
            var Res    = Request.CreateResponse();
            var Result = new Res();

            try
            {
                if (_param != null)
                {
                    await Task.Run(() => _advertisementService.Delete(_param));

                    Result.Status     = true;
                    Result.Message    = "Xóa thành công";
                    Result.StatusCode = HttpStatusCode.OK;
                }
                else
                {
                    Result.Status     = false;
                    Result.Message    = "Xóa thất bại";
                    Result.StatusCode = HttpStatusCode.BadRequest;
                }
                Res.Content = new StringContent(JsonConvert.SerializeObject(Result));
                return(Res);
            }
            catch (Exception ex)
            {
                Result.Status     = false;
                Result.Message    = "Có lỗi xảy ra trong quá trình xóa " + ex.Message;
                Result.StatusCode = HttpStatusCode.BadRequest;
                throw new Exception(ex.Message);
            }
        }
Esempio n. 4
0
        public IViewComponentResult Invoke(string categoryName)
        {
            var section = _sectionService.GetByName(categoryName);

            if (section == null)
            {
                return(View(new AdvertisementModel()));
            }
            var adv = _advertisementService.GetBySectionId(section.Id);

            if (adv == null)
            {
                return(View(new AdvertisementModel()));
            }
            var model = new AdvertisementModel
            {
                Id         = adv.Id,
                PictureUrl = _pictureService.GetPictureUrl(adv.PictureId),
                UrlAddress = adv.UrlAddress,
                CodeFlash  = adv.CodeFlash,
                FlashCode  = adv.FlashCode,
                Target     = adv.TargetId == true ? "_parent" : ""
            };

            return(View(model));
        }
Esempio n. 5
0
        public IViewComponentResult Invoke()
        {
            var section = _sectionService.GetByName("PostSectionRigth");

            if (section == null)
            {
                return(Content(""));
            }
            var adv = _advertisementService.GetBySectionId(section.Id);

            if (adv == null)
            {
                return(Content(""));
            }
            var model = new AdvertisementModel
            {
                Id         = adv.Id,
                PictureUrl = _pictureService.GetPictureUrl(adv.PictureId),
                UrlAddress = adv.UrlAddress,
                CodeFlash  = adv.CodeFlash,
                FlashCode  = adv.FlashCode,
                Target     = adv.TargetId == true ? "_parent" : "",
                IsApproved = adv.IsApproved
            };

            return(View(model));
        }
Esempio n. 6
0
        public static async Task <int> AddPostAsync(AdvertisementModel itemModel)
        {
            var sql = $@"INSERT INTO advertisement(ItemName, ItemDescription, ItemCategory,	ItemCount, City, Tele, Price, Con, image, Negotiable, Created,	Updated) "+
                      "VALUES(@ItemName, @ItemDescription, @ItemCategory, @ItemCount, @City, @Tele, @Price, @Con, @image, @Negotiable, @Created, @Updated)";

            var model = new AdvertisementModel
            {
                ItemName        = itemModel.ItemName,
                ItemDescription = itemModel.ItemDescription,
                ItemCategory    = itemModel.ItemCategory,
                ItemCount       = itemModel.ItemCount,
                City            = itemModel.City,
                Tele            = itemModel.Tele,
                Price           = itemModel.Price,
                Image           = itemModel.Image,
                Con             = itemModel.Con,
                Negotiable      = itemModel.Negotiable,
            };

            await Task.Run(async() =>
            {
                model.Image = await ImageProcessor.GetImage(itemModel.Image);
            });

            return(SqlDataAccess.SaveData(sql, model));
        }
Esempio n. 7
0
        public async Task <HttpResponseMessage> GetByIdAsync(AdvertisementModel _params)
        {
            var Res    = Request.CreateResponse();
            var Result = new Res();

            try
            {
                var data = await Task.Run(() => _advertisementService.GetById(_params));

                if (data != null)
                {
                    Result.Data       = data;
                    Result.Status     = true;
                    Result.Message    = "Call API Success";
                    Result.StatusCode = HttpStatusCode.OK;
                }
                else
                {
                    Result.Data       = null;
                    Result.Status     = false;
                    Result.Message    = "Không tìm thấy dữ liệu";
                    Result.StatusCode = HttpStatusCode.InternalServerError;
                }
                Res.Content = new StringContent(JsonConvert.SerializeObject(Result));
                return(Res);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 8
0
        public async Task <IActionResult> Create(AdvertisementModel model)
        {
            if (ModelState.IsValid)
            {
                Advertisement advertisement = new Advertisement
                {
                    CodeFlash  = model.CodeFlash,
                    CreateDate = DateTime.Now,
                    EndDate    = model.EndDate,
                    FlashCode  = model.FlashCode,
                    IsApproved = model.IsApproved,
                    PictureId  = model.PictureId,
                    SectionId  = model.SectionId,
                    StartDate  = model.StartDate,
                    TargetId   = model.TargetId,
                    UrlAddress = model.UrlAddress
                };
                _context.Add(advertisement);
                await _context.SaveChangesAsync();

                SuccessNotification("Kayıt Eklendi");
                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
Esempio n. 9
0
        public ActionResult Edit(AdvertisementModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            try
            {
                //Update
                if (ModelState.IsValid)
                {
                    var advertisement = _advertisementService.GetAdvertisementById(model.Id);
                    advertisement = new ModelsMapper().CreateMap <AdvertisementModel, Advertisement>(model, advertisement);
                    advertisement.UpdatedOnUtc = DateTime.UtcNow;
                    _advertisementService.UpdateAdvertisement(advertisement);
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception exc)
            {
                ModelState.AddModelError("", exc.Message + "<br />" + exc.InnerException.InnerException.Message);
            }

            PrepareAdvertisementModel(model, null, false, true);
            //AddLocales(_languageService, model.Locales);
            //PrepareAclModel(model, null, false);
            PrepareStoresMappingModel(model, null, false);
            return(View());
        }
Esempio n. 10
0
        // GET: Admin/Advertisements/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Advertisement advertisement = await _context.Advertisements
                                          .FirstOrDefaultAsync(m => m.Id == id);

            AdvertisementModel model = new AdvertisementModel
            {
                Id         = advertisement.Id,
                StartDate  = advertisement.StartDate,
                EndDate    = advertisement.EndDate,
                PictureId  = advertisement.PictureId,
                CodeFlash  = advertisement.CodeFlash,
                CreateDate = advertisement.CreateDate,
                SectionId  = advertisement.SectionId,
                FlashCode  = advertisement.FlashCode,
                IsApproved = advertisement.IsApproved,
                TargetId   = advertisement.TargetId,
                UrlAddress = advertisement.UrlAddress
            };

            PrepareCompanyList(model.AvailableSections);
            if (model.Id == 0)
            {
                return(NotFound());
            }

            return(View(model));
        }
Esempio n. 11
0
 public ListViewModel(IEventAggregator eventAggregator, IAdvertisementAsyncService service)
 {
     _eventAggregator    = eventAggregator;
     _service            = service;
     _advertisementModel = new AdvertisementModel(service);
     UpdateList();
 }
        //
        // GET: /CPAdvertising/

        public ActionResult Advertisement()
        {
            ViewBag.CurrentMainTab     = "Home";
            ViewBag.CurrentSubTab      = "ControlPanel";
            ViewBag.CurrentSuperSubTab = "Advertising";

            List <SectionModel> lstSections = new List <SectionModel>();

            lstSections.Add(new SectionModel
            {
                Id          = 1111,
                SectionName = "Section",
                LanguageId  = CurrentLanguage.Id
            });

            lstSections.AddRange(SectionMap.Map(_repoSection.GetList(x => x.LanguageId == CurrentLanguage.Id).ToList()));

            ViewBag.Sections = new SelectList(lstSections, "Id", "SectionName");

            List <EngineeredToModel> lstEngineered = new List <EngineeredToModel>();

            lstEngineered.Add(
                new EngineeredToModel
            {
                Id           = 0,
                EngineeredTo = "Engineered To"
            }
                );

            lstEngineered.Add(
                new EngineeredToModel
            {
                Id           = 1,
                EngineeredTo = "Visitors Only"
            }
                );

            lstEngineered.Add(
                new EngineeredToModel
            {
                Id           = 2,
                EngineeredTo = "Leonni Users Only"
            }
                );

            lstEngineered.Add(
                new EngineeredToModel
            {
                Id           = 3,
                EngineeredTo = "Visitors and Users"
            }
                );

            ViewBag.Engineered = new SelectList(lstEngineered, "EngineeredTo", "EngineeredTo");

            AdvertisementModel objAdvertisement = new AdvertisementModel();

            return(View(objAdvertisement));
        }
Esempio n. 13
0
        // GET: Admin/Advertisements/Create
        public IActionResult Create()
        {
            AdvertisementModel model = new AdvertisementModel();

            PrepareCompanyList(model.AvailableSections, true, "Reklemın Çıkacağı yeri Seçiniz");

            return(View(model));
        }
Esempio n. 14
0
        public ViewResult AdView(int id)
        {
            AdvertRepository   advert = new AdvertRepository();
            AdvertisementModel model  = advert.GetAdvertisement(id);

            ViewData["Adverts"] = model;
            ViewBag.Name        = HttpContext.Session.GetString(SessionName);
            return(View());
        }
Esempio n. 15
0
        public override async Task <IAdvertisementModel> IndexAsync(HttpContext context, CancellationToken cancellationToken)
        {
            IAdvertisementModel model = new AdvertisementModel();


            await PoulateDropDownListAsync(model, cancellationToken);

            return(model);
        }
Esempio n. 16
0
        public ActionResult AdvertisementEdit(AdvertisementModel model)
        {
            AdvertisementDAO.SetAdvertisementItem(model);
            ViewBag.SiteID = model.SiteID;
            ViewBag.MenuID = model.MenuID;
            ViewBag.Exit   = true;

            return(View(model));
        }
Esempio n. 17
0
        public AdvertisementModel ToViewModel()
        {
            AdvertisementModel am = new AdvertisementModel();

            am.title = this.Title;
            am.url   = this.Url;
            am.src   = this.ImgUrl;
            return(am);
        }
Esempio n. 18
0
        public async Task <int> AddNewAdvertisement(AdvertisementModel model)
        {
            var newAdvertisement = new Advertisements()
            {
                Userid          = model.Userid,
                Ondisplay       = true,
                Rental          = model.Rental,
                PostalCode      = model.PostalCode,
                ContactPhoneNum = model.ContactPhoneNum,
                ContactPerson   = model.ContactPerson,
                Title           = model.Title,
                Description     = model.Description,
                Country         = model.Country,
                Province        = model.Province,
                City            = model.City,
                Streetname      = model.Streetname,
                Streetnum       = model.Streetnum,
                Bedroomsnum     = model.Bedroomsnum,
                Bathroomsnum    = model.Bathroomsnum,
                Hydro           = model.Hydro,
                Heat            = model.Heat,
                Water           = model.Water,
                Internet        = model.Internet,
                Parkingnum      = model.Parkingnum,
                Agreementtype   = model.Agreementtype,
                Moveindate      = model.Moveindate,
                Petfriendly     = model.Petfriendly,
                Size            = model.Size,
                Furnished       = model.Furnished,
                Laundry         = model.Laundry,
                Dishwasher      = model.Dishwasher,
                Fridge          = model.Fridge,
                Airconditioning = model.Airconditioning,
                Smokingpermit   = model.Smokingpermit,
                Postdate        = DateTime.UtcNow
            };

            newAdvertisement.AdvertisementGallery = new List <AdvertisementGallery>();
            if (model.Gallery != null)
            {
                foreach (var file in model.Gallery)
                {
                    newAdvertisement.AdvertisementGallery.Add(new AdvertisementGallery()
                    {
                        URL  = file.URL,
                        Name = file.Name
                    });
                }
            }


            await _context.Advertisements.AddAsync(newAdvertisement);

            await _context.SaveChangesAsync();

            return(newAdvertisement.Adid);
        }
Esempio n. 19
0
        /*==Get By Id==*/
        public AdvertisementModel GetById(AdvertisementModel _params)
        {
            var data = _uow.PromotionRepo.SQLQuery <AdvertisementModel>("sp_Advertisement_GetById " +
                                                                        "@Advertisement_ID",
                                                                        new SqlParameter("Advertisement_ID", SqlDbType.Int)
            {
                Value = _params.Advertisement_ID
            }).FirstOrDefault();

            return(data);
        }
Esempio n. 20
0
        public async Task <IActionResult> Create()
        {
            AdvertisementModel model = new AdvertisementModel
            {
                Brands = await DB.BrandRepository.Get(),
                Models = await DB.ModelRepository.Get(),
                Cities = await DB.CityRepository.Get(),
                Colors = await DB.ColorRepository.Get()
            };

            return(View(model));
        }
Esempio n. 21
0
        public ActionResult Create()
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            var model = new AdvertisementModel();

            PrepareAdvertisementModel(model, null, true, true);
            //AddLocales(_languageService, model.Locales);
            //PrepareAclModel(model, null, false);
            PrepareStoresMappingModel(model, null, false);
            return(View(model));
        }
        public IActionResult Update(AdvertisementModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewData["ErrorMessage"] = "Güncelleme başarısız";
                return(View(model));
            }

            var entitiy = _mapper.Map <Advertisement>(model);
            var result  = _advertisementService.UpdateAdvertisement(entitiy);

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 23
0
        public ActionResult Index()
        {
            if (Session["UserId"] == null)
            {
                return Redirect("/admin/login");
            }

            AdvertisementModel model = new AdvertisementModel();

            AdvertisementService advertisementService = new AdvertisementService();
            model.Advertisements = advertisementService.GetAdvertisements();

            return View(model);
        }
Esempio n. 24
0
        public async System.Threading.Tasks.Task <AuthResponseModel> PostAdAsync(AdvertisementModel adModel)
        {
            var result         = AdvertisementProcessor.AddPostAsync(adModel);
            var verifyResponse = SetResponse(await result);

            if (IsVerified)
            {
                return(SetResponse(5));
            }
            else
            {
                return(verifyResponse);
            }
        }
        public AuthResponseModel PostAd(AdvertisementModel adModel)
        {
            var result         = AdvertisementProcessor.AddPost(adModel);
            var verifyResponse = SetResponse(result);

            if (IsVerified)
            {
                return(SetResponse(5));
            }
            else
            {
                return(verifyResponse);
            }
        }
        public IActionResult Advertisement(int id)
        {
            var advertisements = _advertisements.GetAll();
            var ad             = advertisements.Find(a => a.Id == id);
            var cat            = _categories.Get(ad.CategoryId);

            var model = new AdvertisementModel()
            {
                Advertisement = ad,
                Category      = cat
            };

            return(View(model));
        }
Esempio n. 27
0
 public static Advertisement Map(AdvertisementModel objModel)
 {
     return(new Advertisement
     {
         Id = objModel.Id,
         CategoryId = objModel.CategoryId,
         DisciplineId = objModel.DisciplineId,
         CountryName = objModel.CountryName,
         UserProfileId = objModel.UserProfileId,
         StateId = objModel.ProvinceId,
         Title = objModel.Title,
         Link = objModel.Link,
         BeginningDay = Convert.ToDateTime(objModel.BeginningDay),
         EngineeredTo = objModel.EngineeredTo
     });
 }
Esempio n. 28
0
        public void Validator_Validates_Empty_Strings()
        {
            var model = new AdvertisementModel()
            {
                Title       = "",
                Description = "",
                Price       = -1
            };

            var result = _sut.Validate(model);

            result.Errors.Count.ShouldBe(3);
            result.Errors[0].ErrorMessage.ShouldBe("This field cannot be empty");
            result.Errors[1].ErrorMessage.ShouldBe("This field cannot be empty");
            result.Errors[2].ErrorMessage.ShouldBe("This field cannot be on minus");
        }
        public async Task <IActionResult> Editad(int Adid, [Bind("Adid,Userid,Ondisplay,Title,Rental,PostalCode,ContactPerson,ContactPhoneNum,Description,Country,Province,City,Streetname,Streetnum,Bedroomsnum,Bathroomsnum,Hydro,Heat,Water,Internet,Parkingnum,Agreementtype,Moveindate,Petfriendly,Size,Furnished,Laundry,Dishwasher,Fridge,Airconditioning,Smokingpermit")] AdvertisementModel advertisement)
        {
            if (Adid != advertisement.Adid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                advertisement.Userid = _userService.GetUserId();
                int returnAdid = await _advertisementRepository.EditAdvertisement(advertisement);

                return(RedirectToAction(nameof(GetAdvertisement), new{ Adid = returnAdid }));
            }
            return(View(advertisement));
        }
Esempio n. 30
0
        /// <summary>
        /// 自訂廣告管理 Index
        /// </summary>
        /// <param name="Advertisement_ID">廣告區 ID</param>
        /// <returns></returns>
        public ActionResult AdsCustomizeIndex(AdsCustomizeSearchModel search, long siteId, long menuId, long Advertisement_ID, int?page)
        {
            if (Request.HttpMethod == "GET")
            {
                if (page == null)
                {
                    WorkV3.Common.Utility.ClearSearchValue();
                }
                else
                {
                    AdsCustomizeSearchModel prevSearch = WorkV3.Common.Utility.GetSearchValue <AdsCustomizeSearchModel>();
                    if (prevSearch != null)
                    {
                        search = prevSearch;
                    }
                }
            }
            else if (Request.HttpMethod == "POST")
            {
                WorkV3.Common.Utility.SetSearchValue(search);
                ViewBag.IsSearchMode = "IsSearchMode";
            }
            ViewBag.Search = search;

            List <AdsCustomizeModel> list = new List <AdsCustomizeModel>();
            Pagination pagination         = new Pagination
            {
                PageIndex = page ?? 1,
                PageSize  = WebInfo.PageSize
            };
            int totalRecord = 0;

            list = AdvertisementDAO.GetAdsCustomize(search, pagination.PageSize, pagination.PageIndex, Advertisement_ID, siteId, out totalRecord);
            pagination.TotalRecord = totalRecord;
            ViewBag.Pagination     = pagination;

            ViewBag.UploadUrl        = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId);
            ViewBag.Advertisement_ID = Advertisement_ID;
            ViewBag.SiteID           = siteId;
            ViewBag.MenuID           = menuId;

            AdvertisementModel ad = AdvertisementDAO.GetAdvertisementItem(Advertisement_ID);

            ViewBag.HasComputerVer = ad.IsUseForComputer;

            return(View(list));
        }
Esempio n. 31
0
        public async Task <IActionResult> Edit(int id, AdvertisementModel model)
        {
            if (id != model.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Advertisement advertisement = new Advertisement
                    {
                        Id         = model.Id,
                        CodeFlash  = model.CodeFlash,
                        CreateDate = DateTime.Now,
                        EndDate    = model.EndDate,
                        FlashCode  = model.FlashCode,
                        IsApproved = model.IsApproved,
                        PictureId  = model.PictureId,
                        SectionId  = model.SectionId,
                        StartDate  = model.StartDate,
                        TargetId   = model.TargetId,
                        UrlAddress = model.UrlAddress
                    };

                    _context.Update(advertisement);
                    await _context.SaveChangesAsync();

                    SuccessNotification("Kayıt Güncellendi");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AdvertisementExists(model.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
        public ActionResult RegisterAdvertisement(AdvertisementModel model, HttpPostedFileBase file)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    string userId = User.Identity.GetUserId();

                    //animal
                    AnimalModel animal = new AnimalModel
                    {
                        name = model.animal.race,
                        type = model.animal.type,
                        race = model.animal.race
                    };

                    if (file != null)
                    {
                        _imageController = new ImageController();
                        animal.photo = new List<ImageModel> { _imageController.GetImage(file) };
                    }

                    using (IDal dal = new Dal())
                        dal.addAdvertissement(DateTime.Now, model.title, model.description, animal, userId);

                    return RedirectToAction("RegisterAdvertisement", new { Message = AdvertisementMessageId.AddAdvertiseSuccess });
                }
                else
                    return View(model);
            }
            else
                return RedirectToAction("Login", "Account");
        }
 public ActionResult ConsultAdvertisementView(AdvertisementModel model)
 {
     return View(model);
 }
Esempio n. 34
0
 public void deleteAdvertissement(AdvertisementModel advertissement)
 {
     bdd.advertissements.Remove(advertissement);
 }