public void InsertPost(RentalPost post) { post.CreateDate = DateTime.Now; post.UpdateDate = DateTime.Now; post.Status = (byte)StatusPost.Approved; _rentalPostRepository.Insert(post); }
public IActionResult Put(int id, [FromBody] PostModel model) { ResponsePostRental response = new ResponsePostRental(); StatusPost statusPost = (StatusPost)model.Status; if (model == null && model?.Status == null) { response = ResponseMessage(statusPost); return(BadRequest(response)); } try { RentalPost updatePost = new RentalPost(); RentalPost rentalPost = _rentalPostService.GetById(id); switch (statusPost) { case StatusPost.Pending: rentalPost.Status = (byte)StatusPost.Pending; _rentalPostService.UppdatePost(rentalPost); break; case StatusPost.Approved: rentalPost.Status = (byte)StatusPost.Approved; _rentalPostService.UppdatePost(rentalPost); break; case StatusPost.Cancel: rentalPost.Status = (byte)StatusPost.Cancel; _rentalPostService.UppdatePost(rentalPost); break; case StatusPost.Setp4: _rentalPostService.DeletePictureForPost(rentalPost.Id); _rentalPostService.DeleteUtilitiesOfPost(rentalPost.Id); _rentalPostService.InsertPicturesForPost(model.PictureIds, rentalPost.Id); _rentalPostService.InsertUtilitiesForPost(model.UtilitiesIds, rentalPost.Id); updatePost = model.ConvertSetp(rentalPost); _rentalPostService.UppdatePost(updatePost); break; case StatusPost.Delete: rentalPost.Status = (byte)StatusPost.Delete; _rentalPostService.UppdatePost(rentalPost); break; default: break; } response = ResponseMessage(StatusPost.Susscess); return(Ok(response)); } catch (Exception ex) { response = ResponseMessage(StatusPost.Susscess); _logger.Error("Post PostRentalController", ex); return(BadRequest(response)); } }
public void UppdatePost(RentalPost post) { try { post.UpdateDate = DateTime.Now; _rentalPostRepository.Update(post); } catch (Exception ex) { return; } }
/// <summary> /// Get product picture (for shopping cart and order details pages) /// </summary> /// <param name="product">Product</param> /// <param name="attributesXml">Attributes (in XML format)</param> /// <returns>Picture</returns> public virtual Picture GetRentalPostPicture(RentalPost product, string attributesXml) { if (product == null) { throw new ArgumentNullException(nameof(product)); } //first, try to get product attribute combination picture var parentGroupedProductPicture = GetPicturesByProductId(product.Id, 1).FirstOrDefault(); return(parentGroupedProductPicture); }
public IActionResult Post([FromBody] PostModel model) { ResponsePostRental response = new ResponsePostRental(); try { RentalPost entity = new RentalPost(); entity = model.ConvertSetp(entity); var provincial = _territoriesServices.GetById(entity.ProvincialId); var Ward = _territoriesServices.GetById(entity.WardId); var District = _territoriesServices.GetById(entity.DistrictId); string addressDeatail = string.Format("{0} , {1} , {2} , {3}", entity.AddressDetail, provincial == null ? "": provincial.Name, District == null ? "": District.Name, Ward == null ? "": Ward.Name); entity.AddressDetail = addressDeatail; var lester = _lesterServices.GetByUserId(AccessControl.User.Id); if (lester == null) { response = ResponseMessage(StatusPost.Error); return(BadRequest(response)); } entity.CreateBy = lester.Id; entity.LesterId = lester.Id; _rentalPostService.InsertPost(entity); if (model.PictureIds != null) { _rentalPostService.InsertPicturesForPost(model.PictureIds, entity.Id); } if (model.UtilitiesIds != null) { _rentalPostService.InsertUtilitiesForPost(model.UtilitiesIds, entity.Id); } response = ResponseMessage(StatusPost.Susscess); return(Ok(response)); } catch (Exception ex) { response = ResponseMessage(StatusPost.Error); _logger.Error("Post PostRentalController", ex); return(BadRequest(response)); } }
public RentalPost ConvertSetp(RentalPost rentalPost) { rentalPost.MonthlyPrice = this.MonthlyPrice.HasValue ? this.MonthlyPrice.Value:0; rentalPost.NumberPhone = this.NumberPhone; rentalPost.Deposit = this.Deposit.HasValue ? this.Deposit.Value:0; rentalPost.NumberOfPeople = this.NumberOfPeople.HasValue ? this.NumberOfPeople.Value:0; rentalPost.CategoryId = this.CategoryId.HasValue ? this.CategoryId.Value:0; rentalPost.RoomNumber = this.RoomNumber.HasValue ? this.RoomNumber.Value:0; rentalPost.TypeGendeRroom = (byte)(this.TypeGendeRroom.HasValue? this.TypeGendeRroom.Value:0); rentalPost.Acreage = this.Acreage.HasValue? this.Acreage.Value:0; rentalPost.InternetMoney = this.InternetMoney.HasValue? this.InternetMoney.Value:0; rentalPost.ElectricityBill = this.ElectricityBill.HasValue? this.ElectricityBill.Value:0; rentalPost.WaterBill = this.WaterBill.HasValue? this.WaterBill.Value:0; rentalPost.Parking = this.Parking; rentalPost.DistrictId = this.DistrictId.HasValue ? this.DistrictId.Value:0; rentalPost.ProvincialId = this.ProvincialId.HasValue ? this.ProvincialId.Value:0; rentalPost.AddressDetail = this.AddressDetail; rentalPost.WardId = this.WardId.HasValue?this.WardId.Value:0; rentalPost.DescriptionInformation = this.DescriptionInformation; rentalPost.TitlePost = this.TitlePost; return(rentalPost); }
public ResponseDetailPage() { Post = new RentalPost(); pictures = new List <Picture>(); }