示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 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));
 }
示例#4
0
 public IHttpActionResult CreateNewSaleListing([FromBody] SaleListingDTO model)
 {
     if (ModelState.IsValid)
     {
         if (_salelistingService.CreateNewSaleListing(model))
         {
             return(Ok());
         }
         return(BadRequest("Annonce blev ikke lavet"));
     }
     return(BadRequest(ModelState));
 }
示例#5
0
 public IHttpActionResult RemoveComment(int id, [FromBody] SaleListingDTO saleviewmodel)
 {
     if (ModelState.IsValid)
     {
         if (_salelistingService.RemoveComment(saleviewmodel, id))
         {
             return(Ok());
         }
         return(NotFound());
     }
     return(BadRequest(ModelState));
 }
示例#6
0
 public IHttpActionResult AddOrUpdateSubscription(eSubscription sub, [FromBody] SaleListingDTO salelistingviewmodel)
 {
     if (ModelState.IsValid)
     {
         if (_salelistingService.AddOrUpdateSubscription(sub, salelistingviewmodel))
         {
             return(Ok());
         }
         return(NotFound());
     }
     return(BadRequest(ModelState));
 }
示例#7
0
 public SaleListingDTO GetSaleListingByID(int id)
 {
     try
     {
         var            salelisting    = _saleListingRepository.GetSaleListing(id);
         SaleListingDTO viewmodelmodel = Mapper.Map <SaleListing, SaleListingDTO>(salelisting);
         return(viewmodelmodel);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
示例#8
0
 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);
     }
 }
示例#9
0
 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);
     }
 }
示例#10
0
 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);
     }
 }
示例#11
0
        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);
            }
        }
示例#12
0
 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);
     }
 }