public async Task <SaleListingDTO> CreateNewSaleListing(SaleListingDTO viewmodel) { string uri = string.Format("create"); var salelistings = await client.GetResponseObject <SaleListingDTO, SaleListingDTO>(uri, eHttpMethodType.POST, viewmodel); return(salelistings); }
public async Task <bool> UpdateSaleListing(SaleListingDTO viewmodel) { string uri = string.Format("update"); var salelistings = await client.GetResponseObject <SaleListingDTO, bool>(uri, eHttpMethodType.PUT, viewmodel); return(salelistings); }
public IHttpActionResult UpdateSaleListing([FromBody] SaleListingDTO viewmodel) { if (ModelState.IsValid) { if (_salelistingService.UpdateSaleListing(viewmodel)) { return(Ok(true)); } return(BadRequest("Annonce blev ikke opdateret")); } return(BadRequest(ModelState)); }
public IHttpActionResult CreateNewSaleListing([FromBody] SaleListingDTO model) { if (ModelState.IsValid) { if (_salelistingService.CreateNewSaleListing(model)) { return(Ok()); } return(BadRequest("Annonce blev ikke lavet")); } return(BadRequest(ModelState)); }
public IHttpActionResult RemoveComment(int id, [FromBody] SaleListingDTO saleviewmodel) { if (ModelState.IsValid) { if (_salelistingService.RemoveComment(saleviewmodel, id)) { return(Ok()); } return(NotFound()); } return(BadRequest(ModelState)); }
public IHttpActionResult AddOrUpdateSubscription(eSubscription sub, [FromBody] SaleListingDTO salelistingviewmodel) { if (ModelState.IsValid) { if (_salelistingService.AddOrUpdateSubscription(sub, salelistingviewmodel)) { return(Ok()); } return(NotFound()); } return(BadRequest(ModelState)); }
public SaleListingDTO GetSaleListingByID(int id) { try { var salelisting = _saleListingRepository.GetSaleListing(id); SaleListingDTO viewmodelmodel = Mapper.Map <SaleListing, SaleListingDTO>(salelisting); return(viewmodelmodel); } catch (Exception ex) { throw; } }
public bool UpdateSaleListing(SaleListingDTO viewmodel) { try { SaleListing updated = Mapper.Map <SaleListingDTO, SaleListing>(viewmodel); SaleListing current = _saleListingRepository.GetSaleListing(viewmodel.ID); current = _createAndUpdateService.UpdateSaleListingFields(current, updated); _saleListingRepository.UpdateSaleListing(current); return(true); } catch (Exception ex) { return(false); } }
public bool AddOrUpdateSubscription(eSubscription sub, SaleListingDTO salelistingviewmodel) { try { SaleListing salelisting = _saleListingRepository.GetSaleListing(salelistingviewmodel.ID); Subscription subscription = _subscriptionService.CreateSubscription(sub); _saleListingRepository.UpdateSaleListingSubscription(salelisting, subscription); //_log.LogSaleListing(salelisting.Owner.ID, salelisting.ID, eLogSaleListingType.Update); return(true); } catch (Exception ex) { return(false); } }
public bool CreateNewSaleListing(SaleListingDTO model) { try { Account acc = _accountRepository.GetAccount(model.CreatedBy.ID); if (acc.Company != null && !string.IsNullOrEmpty(acc.Company.VAT)) { var sale = Mapper.Map <SaleListingDTO, SaleListing>(model); var product = _productRepository.GetProductTypeByID(model.ProductType.ID); var salelisting = _createAndUpdateService.CreateSaleListingObject(sale, acc, product); salelisting = _saleListingRepository.AddSaleListing(salelisting); return(true); } return(false); } catch (Exception ex) { return(false); } }
public bool RemoveComment(SaleListingDTO saleviewmodel, int id) { try { SaleListing salelisting = _saleListingRepository.GetSaleListing(saleviewmodel.ID); var comment = salelisting.Comments.FirstOrDefault(e => e.ID == id); if (comment != null) { salelisting.Comments.Remove(comment); _saleListingRepository.UpdateSaleListing(salelisting); //_log.LogSaleListing(salelisting.Owner.ID, salelisting.ID, eLogSaleListingType.Comment); return(true); } return(false); } catch (Exception ex) { return(false); } }
public bool AddImageSaleListing(SaleListingDTO viewmodel, ImageUploadDTO img) { try { if (_imageService.ValidateExtension(img.FileName)) { string imgurl = _imageService.SaveImageToFolder(img); Image image = new Image { ImageURL = imgurl, Type = img.ImageType }; SaleListing salelisting = _saleListingRepository.GetSaleListing(viewmodel.ID); salelisting.Images.Add(image); _saleListingRepository.UpdateSaleListing(salelisting); //_log.LogSaleListing(salelisting.Owner.ID, salelisting.ID, eLogSaleListingType.Update); return(true); } return(false); } catch (Exception ex) { return(false); } }