public ActionResult AdDetails(int AdId) { HttpCookie nameCookie = Request.Cookies["_RRAUN"]; if (nameCookie != null) { AdDetailsModel model = new AdDetailsModel(); InformationServiceWrapper objservice = new InformationServiceWrapper(); model = objservice.FetchAdDetails(AdId); ViewBag.AdId = model.AdID; //ViewBag.Title = model.txtAddTitle; ViewBag.Description = model.txtAdDescription; ViewBag.SubCategoryName = model.txtSubCategoryName; ViewBag.Category = model.Category; ViewBag.Price = model.txtPrice; ViewBag.Quantity = model.txtQuantity; ViewBag.Unit = model.SellingUnit; return(View()); } else { return(RedirectToAction("Login", "Admin")); } }
internal AdDetailsModel MapAdDetailsEntityToAdDetailsModel(AdDetailsEntity AdEntity) { AdDetailsModel AdObj; if (AdEntity != null) { AdObj = new AdDetailsModel(); AdObj.AdID = AdEntity.AdID; AdObj.txtAddTitle = AdEntity.Title; AdObj.Category = AdEntity.Category; AdObj.txtSubCategoryName = AdEntity.txtSubCategoryName; AdObj.txtAdDescription = AdEntity.AdDescription; AdObj.txtPrice = AdEntity.Price; AdObj.txtQuantity = AdEntity.Quantity; AdObj.SellingUnit = AdEntity.SellingUnit; AdObj.Image = AdEntity.Image; AdObj.Location = AdEntity.Location; AdObj.Name = AdEntity.Name; AdObj.MobileNuber = AdEntity.MobileNumber; AdObj.PostedDate = AdEntity.PostedDate; return(AdObj); } else { return(null); } }
internal List <AdDetailsModel> MapAdDetailsEntityListToAdDetailsModel(List <AdDetailsEntity> ListEntity) { AdDetailsModel AdObj = new AdDetailsModel(); List <AdDetailsModel> adListObj = new List <AdDetailsModel>(); if (ListEntity != null) { foreach (AdDetailsEntity item in ListEntity) { AdObj = new AdDetailsModel(); AdObj.AdID = item.AdID; AdObj.txtAddTitle = item.Title; AdObj.Category = item.Category; AdObj.txtSubCategoryName = item.txtSubCategoryName; AdObj.txtAdDescription = item.AdDescription; AdObj.txtPrice = item.Price; AdObj.txtQuantity = item.Quantity; AdObj.SellingUnit = item.SellingUnit; AdObj.Image = item.Image; adListObj.Add(AdObj); } return(adListObj); } else { return(null); } }
public ActionResult RetrieveImage(int AdId) { HttpCookie UserIdCookie = Request.Cookies["_RRUID"]; Utility en = new Utility(); if (UserIdCookie != null) { AdDetailsModel ModelINPUT = new AdDetailsModel(); AdDetailsModel ModelOut = new AdDetailsModel(); ModelINPUT.AdID = AdId; ModelINPUT.UserID = Convert.ToInt32(en.Decrypt(UserIdCookie["_RRUID"])); InformationServiceWrapper InfoObj = new InformationServiceWrapper(); ModelOut = InfoObj.GetImage(ModelINPUT); if (ModelOut != null) { return(File(ModelOut.Image, "image/jpg")); } else { return(null); } } else { return(null); } }
public void GetAdDetails_AdIsNew_GetAdFromRepoAndPopulateIsNewTrue() { // Given Ad ad = new Ad(); ad.CreationDate = new DateTime(2012, 02, 18); ad.CreatedBy = new User { Firstname = "Michel" }; ad.City = new City { Label = "Ville" }; var adRepoMock = new Moq.Mock <IAdRepository>(); adRepoMock.Setup(r => r.GetAdType(17)).Returns(AdTypeEnum.Ad); adRepoMock.Setup(r => r.GetAdById <Ad>(17)).Returns(ad); var helperMock = new Moq.Mock <IHelperService>(); helperMock.Setup(s => s.GetCurrentDateTime()).Returns(new DateTime(2012, 02, 20)); AdDetailsServices service = new AdDetailsServices(adRepoMock.Object, helperMock.Object); // When AdDetailsModel actual = service.GetAdDetails(17); // Then Assert.IsTrue(actual.IsNew); }
public int SPInsertAdViewsStatistics(AdDetailsModel Model) { AdDetailsModel ModelObj = new AdDetailsModel(); ManagementObjectMapper objMapper = new ManagementObjectMapper(); ServiceLayer.ManagementService ManObj = new ManagementService(); return(ManObj.SPInsertAdViewsStatistics(objMapper.MapAddPostModelToAddPostEntity(Model))); }
public void UpdateAdDetails(AdDetailsModel Obj) { ManagementObjectMapper objMapper = new ManagementObjectMapper(); AdDetailsEntity Entity = new AdDetailsEntity(); Entity = objMapper.MapAddPostModelToAddPostEntity(Obj); ServiceLayer.ManagementService ManObj = new ManagementService(); ManObj.UpdateAdDetails(Entity); }
public int InsertAdPostByAdmin(AdDetailsModel ModelObj) { ManagementObjectMapper objMapper = new ManagementObjectMapper(); AdDetailsEntity Entity = new AdDetailsEntity(); Entity = objMapper.MapAddPostModelToAddPostEntity(ModelObj); ServiceLayer.ManagementService ManObj = new ManagementService(); return(ManObj.InsertAdPostByAdmin(Entity)); }
public int UploadImage(AdDetailsModel obj) { ManagementObjectMapper objMapper = new ManagementObjectMapper(); AdDetailsEntity Entity = new AdDetailsEntity(); Entity = objMapper.MapAddPostModelToAddPostEntity(obj); ServiceLayer.ManagementService ManObj = new ManagementService(); return(ManObj.UploadImage(Entity)); }
public AdDetailsModel SPRRGetAdDisplayDetails(Int32 AdId) { AdDetailsModel Model = new AdDetailsModel(); AdDetailsEntity Entity = new AdDetailsEntity(); ServiceLayer.InformationService obj = new InformationService(); InformationObjectMapper ObjMapper = new InformationObjectMapper(); Entity = obj.SPRRGetAdDisplayDetails(AdId); Model = ObjMapper.MapAdDetailsEntityToAdDetailsModel(Entity); return(Model); }
public AdDetailsModel FetchAdDetails(int AdId) { AdDetailsModel modelObj = new AdDetailsModel(); AdDetailsEntity EntityObj = new AdDetailsEntity(); ServiceLayer.InformationService obj = new InformationService(); InformationObjectMapper ObjMapper = new InformationObjectMapper(); EntityObj = obj.FetchAdDetails(AdId); modelObj = ObjMapper.MapAdDetailsEntityToModel(EntityObj); return(modelObj); }
public AdDetailsModel GetAdDetails(long adId) { AdTypeEnum adType = _adRepository.GetAdType(adId); if (adType == AdTypeEnum.Undefined) { return(null); } AdDetailsModel model = CreateAdDetailsModelFromAd(adType, adId); return(model); }
public AdDetailsModel GetImage(AdDetailsModel Detobj) { AdDetailsModel modelObjoutPut = new AdDetailsModel(); AdDetailsEntity EntityObj1 = new AdDetailsEntity(); AdDetailsEntity EntityObj2 = new AdDetailsEntity(); ServiceLayer.InformationService obj = new InformationService(); InformationObjectMapper ObjMapper = new InformationObjectMapper(); EntityObj1 = ObjMapper.MapAdDetailsModelToEntity(Detobj); EntityObj2 = obj.GetImage(EntityObj1); modelObjoutPut = ObjMapper.MapAdDetailsEntityToModel(EntityObj2); return(modelObjoutPut); }
public void GetAdDetails_AdDoesNotExist_ReturnNull() { // Given var adRepoMock = new Moq.Mock <IAdRepository>(); adRepoMock.Setup(r => r.GetAdType(17)).Returns(AdTypeEnum.Undefined); AdDetailsServices service = new AdDetailsServices(adRepoMock.Object, null); // When AdDetailsModel actual = service.GetAdDetails(17); // Then Assert.IsNull(actual); }
public ActionResult UserDetails(FormCollection fnPost) { int AdId; ManagementServiceWrapper ObjService = new ManagementServiceWrapper(); AdDetailsModel obj = new AdDetailsModel(); obj.txtAddTitle = fnPost["txtAddTitle"]; obj.Category = fnPost["ddlCategory"]; obj.txtAdDescription = fnPost["txtAdDescription"]; obj.txtPrice = Convert.ToInt32(fnPost["txtPrice"]); obj.txtQuantity = Convert.ToInt32(fnPost["txtQuantity"]); obj.SellingUnit = fnPost["ddlUnit"]; obj.UserID = 1; AdId = ObjService.InsertAddPostDetails(obj); return(Json(AdId, JsonRequestBehavior.AllowGet)); }
public ActionResult AdDisplayWithPhoneNumber(int AdId) { HttpCookie UserIdCookie = Request.Cookies["_RRUID"]; HttpCookie PhoneNumberCookie = Request.Cookies["_RRUPn"]; if (UserIdCookie != null && PhoneNumberCookie != null) { AdDetailsModel model = new AdDetailsModel(); InformationServiceWrapper objservice = new InformationServiceWrapper(); model = objservice.SPRRGetAdDisplayDetails(AdId); ViewBag.IntAdId = model.AdID; ViewBag.AdId = model.AdID + ".jpg"; ViewBag.Title = model.txtAddTitle; ViewBag.Description = model.txtAdDescription; ViewBag.Category = model.Category; ViewBag.Price = model.txtPrice; ViewBag.Quantity = model.txtQuantity; ViewBag.Unit = model.SellingUnit; ViewBag.Name = model.Name; ViewBag.MobileNumber = model.MobileNuber.ToString(); ViewBag.Location = model.Location; ViewBag.AdPostedDate = model.PostedDate; if (model.Category == "Fruit" || model.Category == "Handloom" || model.Category == "Equipment" || model.Category == "Vegetable" || model.Category == "Others") { ViewBag.DefinedTitle = model.txtSubCategoryName + " " + model.txtQuantity + " " + model.SellingUnit + " at Price Rs." + model.txtPrice + " Per " + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); } else { ViewBag.DefinedTitle = model.Category + " " + model.txtQuantity + " " + model.SellingUnit + " at Price Rs." + model.txtPrice + " Per " + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); } ViewBag.DefinedUnit = " /" + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); ManagementServiceWrapper ManObj = new ManagementServiceWrapper(); Utility en = new Utility(); AdDetailsModel StatisticsObj = new AdDetailsModel(); StatisticsObj.UserID = Convert.ToInt32(en.Decrypt(UserIdCookie["_RRUID"])); StatisticsObj.MobileNuber = Convert.ToInt64(en.Decrypt(PhoneNumberCookie["_RRUPn"])); StatisticsObj.AdID = model.AdID;; ManObj.SPInsertAdViewsStatistics(StatisticsObj); return(View("AdDisplay")); } else { return(RedirectToAction("Login", "User")); } }
public HttpResponseMessage Get(long id) { HttpResponseMessage response; Ad ad = _adServices.GetAdById(id); if (ad == null) { response = new HttpResponseMessage(HttpStatusCode.NotFound); } else { AdDetailsModel adModel = new AdDetailsModel(ad); response = Request.CreateResponse(HttpStatusCode.OK, adModel); } return(response); }
internal AdDetailsEntity MapAddPostModelToAddPostEntity(AdDetailsModel Model) { AdDetailsEntity Entity = new AdDetailsEntity(); Entity.AdID = Model.AdID; Entity.Title = Model.txtAddTitle; Entity.Category = Model.Category; Entity.txtSubCategoryName = Model.txtSubCategoryName; Entity.AdDescription = Model.txtAdDescription; Entity.Price = Model.txtPrice; Entity.Quantity = Model.txtQuantity; Entity.UserID = Model.UserID; Entity.SellingUnit = Model.SellingUnit; Entity.MobileNumber = Model.MobileNuber; Entity.Image = Model.Image; return(Entity); }
public HttpResponseMessage GetAdDetails(HttpRequestMessage request, [FromBody] int adId) { return(GetHttpResponse(request, () => { HttpResponseMessage response = null; Ad ad = adRepository.Get(adId); AdDetailsModel adDetails = new AdDetailsModel(); List <string> adApplicantUserIds = new List <string>(); adDetails.AdDetails = ad; adApplicantUserIds = adApplicationRespository.GetAdApplicant(ad.AdId); foreach (var adApplicant in adApplicantUserIds) { Account account = UserManager.FindById(adApplicant); if (account == null) { continue; } UserAccountModel userAccountModel = new UserAccountModel() { Email = account.Email, FirstName = account.FirstName, LastName = account.LastName, UserName = account.UserName, SubscriptionStatus = account.SubscriptionStatus, PhoneNumber = account.PhoneNumber, UserId = account.Id, CurrentRating = account.CurrentRating, NumberOfReviews = account.NumberOfReviews }; adDetails.AdApplicantDetails.Add(userAccountModel); } response = request.CreateResponse(HttpStatusCode.OK, adDetails); return response; })); }
internal AdDetailsModel MapAdDetailsEntityToModel(AdDetailsEntity Entity) { if (Entity != null) { AdDetailsModel MODEL = new AdDetailsModel(); MODEL.AdID = Entity.AdID; MODEL.txtAddTitle = Entity.Title; MODEL.txtAdDescription = Entity.AdDescription; MODEL.Category = Entity.Category; MODEL.txtSubCategoryName = Entity.txtSubCategoryName; MODEL.txtPrice = Entity.Price; MODEL.txtQuantity = Entity.Quantity; MODEL.SellingUnit = Entity.SellingUnit; MODEL.Image = Entity.Image; return(MODEL); } else { return(null); } }
public ActionResult AdDetails(int AdId) { HttpCookie UserIdCookie = Request.Cookies["_RRUID"]; HttpCookie KeyCookie = Request.Cookies["_RRPS"]; Utility en = new Utility(); if (UserIdCookie != null) { AdDetailsModel model = new AdDetailsModel(); InformationServiceWrapper objservice = new InformationServiceWrapper(); Int32 Userid = Convert.ToInt32(en.Decrypt(UserIdCookie["_RRUID"])); List <Int32> UserAdList = new List <int>(); UserAdList = objservice.getAdIdsWithUserid(Userid); if (UserAdList.Contains(AdId)) { model = objservice.FetchAdDetails(AdId); ViewBag.AdId = model.AdID; //ViewBag.Title = model.txtAddTitle; ViewBag.Description = model.txtAdDescription; ViewBag.SubCategoryName = model.txtSubCategoryName; ViewBag.Category = model.Category; ViewBag.Price = model.txtPrice; ViewBag.Quantity = model.txtQuantity; ViewBag.Unit = model.SellingUnit; return(View()); } else { return(RedirectToAction("UserAccount", "User")); } } else { return(RedirectToAction("Login", "User")); } }
public void GetAdDetails_RealEstateAdExists_GetAdFromRepoAndReturnMotoAdModel() { // Given RealEstateAd ad = new RealEstateAd() { Id = 17 }; ad.CreationDate = new DateTime(2012, 02, 18); ad.CreatedBy = new User { Firstname = "Michel" }; ad.City = new City { Label = "Ville" }; var repoMock = new Moq.Mock <IRepository>(); repoMock.Setup(x => x.Get <BaseAd>(17)).Returns(ad as BaseAd); var adRepoMock = new Moq.Mock <IAdRepository>(); adRepoMock.Setup(r => r.GetAdType(17)).Returns(AdTypeEnum.RealEstateAd); adRepoMock.Setup(r => r.GetAdById <RealEstateAd>(17)).Returns(ad); var helperMock = new Moq.Mock <IHelperService>(); helperMock.Setup(s => s.GetCurrentDateTime()).Returns(new DateTime(2012, 02, 20)); AdDetailsServices service = new AdDetailsServices(adRepoMock.Object, helperMock.Object); // When AdDetailsModel actual = service.GetAdDetails(17); // Then Assert.AreEqual(17, actual.AdId); Assert.IsTrue(actual is RealEstateAdDetailsModel); }
public ActionResult AdDisplay(int AdId) { HttpCookie nameCookie = Request.Cookies["_RRAUN"]; if (nameCookie != null) { AdDetailsModel model = new AdDetailsModel(); InformationServiceWrapper objservice = new InformationServiceWrapper(); model = objservice.SPRRGetAdDisplayDetails(AdId); ViewBag.IntAdId = model.AdID; ViewBag.AdId = model.AdID + ".jpg"; ViewBag.Title = model.txtAddTitle; ViewBag.Description = model.txtAdDescription; ViewBag.Category = model.Category; ViewBag.Price = model.txtPrice; ViewBag.Quantity = model.txtQuantity; ViewBag.Unit = model.SellingUnit; ViewBag.Name = model.Name; ViewBag.MobileNumber = model.MobileNuber.ToString(); ViewBag.Location = model.Location; ViewBag.AdPostedDate = model.PostedDate; ViewBag.DefinedTitle = model.Category + " " + model.txtQuantity + " " + model.SellingUnit + " at Price Rs." + model.txtPrice + " Per " + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); ViewBag.DefinedUnit = " /" + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); //searchingData //ViewBag.SearchOption = "CATEGORY"; //ViewBag.PageNumber = PageNumber; //ViewBag.CategoryID = CategoryID; return(View("/Views/AddPost/AdDisplay.cshtml")); } else { return(RedirectToAction("Login", "Admin")); } }
public ActionResult AdDisplay(int AdId) { AdDetailsModel model = new AdDetailsModel(); InformationServiceWrapper objservice = new InformationServiceWrapper(); model = objservice.SPRRGetAdDisplayDetails(AdId); ViewBag.IntAdId = model.AdID; ViewBag.AdId = model.AdID + ".jpg"; ViewBag.Title = model.txtAddTitle; ViewBag.Description = model.txtAdDescription; ViewBag.Category = model.Category; ViewBag.SubCategoryName = model.txtSubCategoryName; ViewBag.Price = model.txtPrice; ViewBag.Quantity = model.txtQuantity; ViewBag.Unit = model.SellingUnit; ViewBag.Name = model.Name; ViewBag.MobileNumber = model.MobileNuber.ToString().Substring(0, 3) + "XXXXXX"; ViewBag.Location = model.Location; ViewBag.AdPostedDate = model.PostedDate.ToString(); if (model.Category == "Fruit" || model.Category == "Handloom" || model.Category == "Equipment" || model.Category == "Vegetable" || model.Category == "Others") { ViewBag.DefinedTitle = model.txtSubCategoryName + " " + model.txtQuantity + " " + model.SellingUnit + " at Price Rs." + model.txtPrice + " Per " + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); } else { ViewBag.DefinedTitle = model.Category + " " + model.txtQuantity + " " + model.SellingUnit + " at Price Rs." + model.txtPrice + " Per " + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); } ViewBag.DefinedUnit = " /" + model.SellingUnit.Substring(0, model.SellingUnit.Length - 1); //searchingData //ViewBag.SearchOption = "CATEGORY"; //ViewBag.PageNumber = PageNumber; //ViewBag.CategoryID = CategoryID; return(View("AdDisplay")); }
public void AdDetailsModel_ctor() { // Given City c = new City() { Label = "Nouméa" }; User u = new User() { Firstname = "Nicolas" }; Category cat = new Category() { Label = "Auto", LabelUrlPart = "Auto", ParentCategory = new Category { Label = "Véhicules", LabelUrlPart = "Vehicules" } }; Ad ad = new Ad() { Id = 17, Title = "title", Price = 1270, City = c, CreatedBy = u, CreationDate = new DateTime(2012, 05, 12, 17, 26, 08), Body = "body", }; cat.AddAd(ad); ad.Images.Add(new AdImage() { Id = Guid.Parse("e9da8b1e-aa77-401b-84e0-a1290130b7b7") }); ad.Images.Add(new AdImage() { Id = Guid.Parse("e9da8b1e-aa77-401b-84e0-a1290130b7b9") }); // When AdDetailsModel model = new AdDetailsModel(ad); // Then Assert.AreEqual("title", model.Title); Assert.AreEqual("Nouméa", model.Location); Assert.AreEqual("Nicolas", model.UserFirstName); Assert.AreEqual("samedi 12 mai 2012 17:26", model.CreationDateString); Assert.AreEqual("body", model.Body); Assert.AreEqual("1 270 Francs", model.Price); Assert.AreEqual(17, model.AdId); Assert.AreEqual(2, model.ImagesIds.Count); Assert.AreEqual("e9da8b1e-aa77-401b-84e0-a1290130b7b7", model.ImagesIds[0]); Assert.AreEqual("e9da8b1e-aa77-401b-84e0-a1290130b7b9", model.ImagesIds[1]); Assert.AreEqual("Auto", model.Category); Assert.AreEqual("Auto", model.CategoryUrlPart); Assert.AreEqual("Véhicules", model.CategoryGroup); Assert.AreEqual("Vehicules", model.CategoryGroupUrlPart); }
public ActionResult FileUpload(HttpPostedFileBase image, Int32 AdId) { HttpCookie UserIdCookie = Request.Cookies["_RRUID"]; Utility en = new Utility(); if (UserIdCookie != null) { string userid = en.Decrypt(UserIdCookie["_RRUID"].ToString()); HttpPostedFileBase file = Request.Files["ImageData"]; if (file != null) { var LENGTH = (file.ContentLength / 1024); var ext = Path.GetExtension(file.FileName); Stream strm = file.InputStream; var ActualImagePath = Path.Combine(Server.MapPath("~/PhotoManagement/Actual/"), Convert.ToString(AdId) + ".jpg"); var CompressedImagePath = Path.Combine(Server.MapPath("~/PhotoManagement/Compressed/"), Convert.ToString(AdId) + ".jpg"); var CompressedDelPath = Path.Combine(Server.MapPath("~/PhotoManagement/Deleted/"), Convert.ToString(AdId) + "_Compressed_Deleted.jpg"); var ActualDelPath = Path.Combine(Server.MapPath("~/PhotoManagement/Deleted/"), Convert.ToString(AdId) + "_Actual_Deleted.jpg"); if (System.IO.File.Exists(CompressedImagePath)) { System.IO.File.Delete(CompressedDelPath); System.IO.File.Move(CompressedImagePath, CompressedDelPath); if (System.IO.File.Exists(ActualImagePath)) { System.IO.File.Delete(ActualDelPath); System.IO.File.Move(ActualImagePath, ActualDelPath); } ReduceImageSize(strm, CompressedImagePath); if (LENGTH >= 350) { ReduceImageSizeForActualImage(strm, ActualImagePath); } else { file.SaveAs(ActualImagePath); } } else { ReduceImageSize(strm, CompressedImagePath); if (LENGTH >= 350) { ReduceImageSizeForActualImage(strm, ActualImagePath); } else { file.SaveAs(ActualImagePath); } } AdDetailsModel obj = new AdDetailsModel(); obj.UserID = Convert.ToInt32(userid); obj.AdID = AdId; obj.Image = ConvertToBytes(file); ManagementServiceWrapper OBJ = new ManagementServiceWrapper(); OBJ.UploadImage(obj); return(Json(AdId, JsonRequestBehavior.AllowGet)); } else { return(Json(AdId, JsonRequestBehavior.AllowGet)); } } else { return(Json(AdId, JsonRequestBehavior.AllowGet)); } }
protected AdDetailsModel CreateAdDetailsModelFromAd(AdTypeEnum adType, long adId) { AdDetailsModel model = null; BaseAd ad = null; // Get the right Ad based on its type switch (adType) { case AdTypeEnum.Ad: ad = _adRepository.GetAdById <Ad>(adId); model = new AdDetailsModel(ad); break; case AdTypeEnum.CarAd: ad = _adRepository.GetAdById <CarAd>(adId); model = new CarAdDetailsModel(ad as CarAd); break; case AdTypeEnum.MotoAd: ad = _adRepository.GetAdById <MotoAd>(adId); model = new MotoAdDetailsModel(ad as MotoAd); break; case AdTypeEnum.OtherVehiculeAd: ad = _adRepository.GetAdById <OtherVehicleAd>(adId); model = new OtherVehicleAdDetailsModel(ad as OtherVehicleAd); break; case AdTypeEnum.SailingBoatAd: ad = _adRepository.GetAdById <SailingBoatAd>(adId); model = new SailingBoatAdDetailsModel(ad as SailingBoatAd, _helperService); break; case AdTypeEnum.MotorBoatAd: ad = _adRepository.GetAdById <MotorBoatAd>(adId); model = new MotorBoatAdDetailsModel(ad as MotorBoatAd, _helperService); break; case AdTypeEnum.MotorBoatEngineAd: ad = _adRepository.GetAdById <MotorBoatEngineAd>(adId); model = new MotorBoatEngineAdDetailsModel(ad as MotorBoatEngineAd); break; case AdTypeEnum.WaterSportAd: ad = _adRepository.GetAdById <WaterSportAd>(adId); model = new WaterSportAdDetailsModel(ad as WaterSportAd); break; case AdTypeEnum.RealEstateAd: ad = _adRepository.GetAdById <RealEstateAd>(adId); model = new RealEstateAdDetailsModel(ad as RealEstateAd); break; default: return(null); } // Compute whether or not this Ad is new (less than 3 days) model.IsNew = ad.CreationDate > _helperService.GetCurrentDateTime().AddHours(-72); return(model); }
public ActionResult AdDetails(FormCollection fnAd) { int success = 0; HttpCookie nameCookie = Request.Cookies["_RRAUN"]; if (nameCookie != null) { ManagementServiceWrapper ObjService = new ManagementServiceWrapper(); AdDetailsModel obj = new AdDetailsModel(); obj.AdID = Convert.ToInt32(fnAd["AdId"]); obj.Category = fnAd["ddlCategoryText"]; obj.txtSubCategoryName = fnAd["txtSubCategoryName"]; obj.txtAdDescription = fnAd["txtAdDescription"]; obj.txtPrice = Convert.ToInt32(fnAd["txtPrice"]); obj.txtQuantity = Convert.ToInt32(fnAd["txtQuantity"]); obj.SellingUnit = fnAd["ddlUnitText"]; HttpPostedFileBase file = Request.Files["myImage"]; if (obj.Category == "Fruit" || obj.Category == "Handloom" || obj.Category == "Equipment" || obj.Category == "Vegetable" || obj.Category == "Others") { obj.txtSubCategoryName = obj.txtSubCategoryName; } else { obj.txtSubCategoryName = obj.Category; } string s = "[^<>'\"/`%-]"; int count = 0; if (System.Text.RegularExpressions.Regex.IsMatch(obj.Category, "^[a-zA-Z0-9 .]")) { count = count + 1; } if (System.Text.RegularExpressions.Regex.IsMatch(obj.txtSubCategoryName, s)) { count = count + 1; } if (System.Text.RegularExpressions.Regex.IsMatch(obj.txtAdDescription, s)) { count = count + 1; } if (System.Text.RegularExpressions.Regex.IsMatch(obj.SellingUnit, "^[a-zA-Z0-9 .]")) { count = count + 1; } if (Regex.Match(obj.txtPrice.ToString(), "[1-9]").Success) { count = count + 1; } if (Regex.Match(obj.txtQuantity.ToString(), "[1-9]").Success) { count = count + 1; } if (count == 6) { ObjService.UpdateAdDetails(obj); success = obj.AdID; return(Json(success, JsonRequestBehavior.AllowGet)); } else { success = -99; return(Json(success, JsonRequestBehavior.AllowGet)); } } else { return(RedirectToAction("Login", "Admin")); } }
// POST api/AdAPI public void Post(AdDetailsModel adModel) { }
public ActionResult AdPostByAdmin(FormCollection fnPost) { int AdId = 0; HttpCookie nameCookie = Request.Cookies["_RRAUN"]; if (nameCookie != null) { ManagementServiceWrapper ObjService = new ManagementServiceWrapper(); AdDetailsModel obj = new AdDetailsModel(); obj.Category = fnPost["ddlCategoryText"]; obj.txtSubCategoryName = fnPost["txtSubCategoryName"]; obj.txtAdDescription = fnPost["txtAdDescription"]; obj.txtPrice = Convert.ToInt32(fnPost["txtPrice"]); obj.txtQuantity = Convert.ToInt32(fnPost["txtQuantity"]); obj.SellingUnit = fnPost["ddlUnitText"]; obj.MobileNuber = Convert.ToInt64(fnPost["txtPhoneNumber"]); if (obj.Category == "Fruit" || obj.Category == "Handloom" || obj.Category == "Equipment" || obj.Category == "Vegetable" || obj.Category == "Others") { obj.txtSubCategoryName = obj.txtSubCategoryName; } else { obj.txtSubCategoryName = obj.Category; } string s = "[^<>'\"/`%-]"; int count = 0; if (System.Text.RegularExpressions.Regex.IsMatch(obj.Category, "^[a-zA-Z0-9 .]")) { count = count + 1; } if (System.Text.RegularExpressions.Regex.IsMatch(obj.txtSubCategoryName, s)) { count = count + 1; } if (System.Text.RegularExpressions.Regex.IsMatch(obj.txtAdDescription, s)) { count = count + 1; } if (System.Text.RegularExpressions.Regex.IsMatch(obj.SellingUnit, "^[a-zA-Z0-9 .]")) { count = count + 1; } if (Regex.Match(obj.txtPrice.ToString(), "[1-9]").Success) { count = count + 1; } if (Regex.Match(obj.txtQuantity.ToString(), "[1-9]").Success) { count = count + 1; } if (count == 6) { AdId = ObjService.InsertAdPostByAdmin(obj); return(Json(AdId, JsonRequestBehavior.AllowGet)); } else { AdId = -1; return(Json(AdId, JsonRequestBehavior.AllowGet)); } } else { return(RedirectToAction("Login", "Admin")); } }