Beispiel #1
0
        public bool DeleteOffer(int referenceA, int referenceB, out string outputMessage)
        {
            Offer referenceOffer = db.Offer.Where(o => o.ReceiverItemId == referenceA && o.SenderItemId == referenceB).FirstOrDefault();

            if (referenceOffer != null)
            {
                OfferDetail referenceDetail = db.OfferDetail.Where(od => od.OfferId == referenceOffer.OfferId).FirstOrDefault();
                try
                {
                    if (referenceDetail != null)
                    {
                        db.OfferDetail.Remove(referenceDetail);
                    }
                    RedirectViewModel redirectSender   = new RedirectViewModel("Index", "Trades", "");
                    RedirectViewModel redirectReceiver = new RedirectViewModel("UserOffers", "Trades", "");
                    SaveNotification(referenceOffer, redirectSender, NotificationType.DeleteTradeSender);
                    SaveNotification(referenceOffer, redirectReceiver, NotificationType.DeleteTradeReceiver);
                    db.Offer.Remove(referenceOffer);
                    db.SaveChanges();
                    outputMessage = "Offer has been removed.";
                    return(true);
                }
                catch
                {
                    outputMessage = Resources.Processing.ProcessError;
                    return(false);
                }
            }
            outputMessage = Resources.Processing.ProcessError;
            return(false);
        }
Beispiel #2
0
 public bool DeleteOffersByItem(Item referenceItem)
 {
     if (referenceItem != null)
     {
         List <Offer> referenceOffers = db.Offer.Where(o => o.ReceiverItemId == referenceItem.ItemId || o.SenderItemId == referenceItem.ItemId).ToList();
         if (referenceOffers != null)
         {
             foreach (Offer offer in referenceOffers)
             {
                 OfferDetail referenceDetail = db.OfferDetail.Where(od => od.OfferId == offer.OfferId).FirstOrDefault();
                 if (referenceDetail != null)
                 {
                     db.OfferDetail.Remove(referenceDetail);
                 }
                 RedirectViewModel redirectSender   = new RedirectViewModel("Index", "Trades", "");
                 RedirectViewModel redirectReceiver = new RedirectViewModel("UserOffers", "Trades", "");
                 SaveNotification(offer, redirectSender, NotificationType.DeleteTradeSender);
                 SaveNotification(offer, redirectReceiver, NotificationType.DeleteTradeReceiver);
                 db.Offer.Remove(offer);
                 db.SaveChanges();
             }
         }
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        public TradesDetailViewModel GetTradeDetails(int receiver, int sender)
        {
            Offer offerRequest = db.Offer.Where(o => o.ReceiverItemId == receiver && o.SenderItemId == sender).FirstOrDefault();

            if (offerRequest != null)
            {
                OfferDetail          offerRequestDetails = db.OfferDetail.Where(od => od.OfferId == offerRequest.OfferId).FirstOrDefault();
                ItemsDetailViewModel receiverItem        = global.GetItemDetail(receiver);
                ItemsDetailViewModel senderItem          = global.GetItemDetail(sender);
                if (receiverItem != null && senderItem != null && offerRequestDetails != null)
                {
                    TradesDetailViewModel detailOffer = new TradesDetailViewModel();
                    detailOffer.OfferId        = offerRequest.OfferId;
                    detailOffer.Confirmed      = offerRequestDetails.Confirmed;
                    detailOffer.ExpirationDate = offerRequestDetails.ExpirationDate;
                    detailOffer.ReceiverItem   = receiverItem;
                    detailOffer.SenderItem     = senderItem;
                    if (offerRequestDetails.Confirmed == 1)
                    {
                        Account receiverAccount = db.Account.Where(a => a.AccountId == offerRequest.ReceiverId).FirstOrDefault();
                        Account senderAccount   = db.Account.Where(a => a.AccountId == offerRequest.AccountId).FirstOrDefault();
                        detailOffer.ReceiverDetails = getContactInformation(receiverAccount);
                        detailOffer.SenderDetails   = getContactInformation(senderAccount);
                    }
                    return(detailOffer);
                }
            }
            return(null);
        }
Beispiel #4
0
        /// <summary>
        /// Löscht die angegebene Angebotsposition;
        /// </summary>
        /// <param name="offerDetail"></param>
        public void DeleteOfferDetail(OfferDetail offerDetail)
        {
            var offer = offerDetail.ParentOffer;

            // Position aus der internen Auflistung entfernen.
            this.GetOfferDetailList(offer.CustomerId, offer.UID).Remove(offerDetail);
            DataManager.OfferDataService.DeleteOfferDetailRow(offer.CustomerId, offerDetail.UID);
        }
Beispiel #5
0
        public async Task <IActionResult> AddDetaisAsync([FromBody] OfferDetail item)
        {
            var user = await _userManager.GetUserAsync(User);

            item.CreatedBy  = user.Id;
            item.ModifiedBy = user.Id;
            return(CreatedAtAction(nameof(AddDetaisAsync), await _offerService.AddDetailsAsync(item)));
        }
Beispiel #6
0
        public async Task <dynamic> AddDetailsAsync(OfferDetail item)
        {
            item.CreatedDate  = DateTime.Now;
            item.ModifiedDate = DateTime.Now;
            await _context.OfferDetails.AddAsync(item);

            return(new { succeeded = await _context.SaveChangesAsync() > 0, data = item });
        }
Beispiel #7
0
        public async Task <OfferDetail> Add(OfferDetail viewModel)
        {
            var model = _mapper.Map <OfferDetailEntity>(viewModel);

            _context.OfferDetails.Add(model);
            await _context.SaveChangesAsync();

            _mapper.Map(model, viewModel);
            return(viewModel);
        }
Beispiel #8
0
        /// <summary>
        /// Gibt eine neue Angebotsposition zurück.
        /// </summary>
        /// <param name="offer">Angebot, für das die neue Position erstellt wird.</param>
        /// <param name="product">Artikel der Angebotsposition.</param>
        public void AddOfferDetail(Offer offer, Product product)
        {
            int posCount = offer.OfferDetails.Count;
            var newRow   = DataManager.OfferDataService.AddOfferDetailRow(offer.CustomerId, offer.UID, product.Artikelnummer, posCount);

            if (newRow != null)
            {
                var detail = new OfferDetail(newRow, offer.CustomerId);
                offer.OfferDetails.Add(detail);
            }
        }
Beispiel #9
0
        private OfferDetail GetDetailDataFromRow(DataRow r)
        {
            OfferDetail d = OfferDetail.CreateDetail();

            d.OfferDetailId = r["id_detalle"].ToString();
            d.ProductId     = r["id_producto"].ToString();
            d.ProductName   = r["Producto"].ToString();
            d.ActualValue   = float.Parse(r["valor_original"].ToString());
            d.Percent       = r["Descuento aplicado"].ToString();
            d.OfferValue    = float.Parse(r["Valor oferta"].ToString());
            return(d);
        }
        private void GetCurrentDetail()
        {
            if (currentOffer.Details.Count.Equals(0))
            {
                currentDetail = OfferDetail.CreateDetail();
                return;
            }
            var row = ProductDataGridView.CurrentRow;

            if (row != null)
            {
                currentDetail = row.DataBoundItem as OfferDetail;
            }
        }
Beispiel #11
0
        public async Task <OfferDetail> Update(OfferDetail viewModel)
        {
            if (viewModel.Id == null)
            {
                throw new ArgumentNullException(nameof(viewModel.Id));
            }
            var data = await _context.OfferDetails.FirstOrDefaultAsync(c => c.Id == viewModel.Id);

            _mapper.Map(viewModel, data);
            _context.Update(data);
            await _context.SaveChangesAsync();

            return(viewModel);
        }
        void dgvOfferDetails_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            myCurrentOfferDetail = dgvOfferDetails.Rows[e.RowIndex].DataBoundItem as OfferDetail;
            if (myCurrentOfferDetail != null)
            {
                var loeschText = string.Format("Lösche Position {0} ({1})", myCurrentOfferDetail.Position, myCurrentOfferDetail.Artikelname);
                this.mToolTip.SetToolTip(btnPositionLoeschen, loeschText);
                this.txtPositionsinfo.Text = myCurrentOfferDetail.Positionsinfo;
                this.txtRowComment.DataBindings.Clear();
                this.txtRowComment.DataBindings.Add("Text", myCurrentOfferDetail, "Artikeltext");
                this.txtRowComment.Text = string.IsNullOrEmpty(this.myCurrentOfferDetail.Artikeltext) ? string.Empty : this.myCurrentOfferDetail.Artikeltext;

                //this.txtRowComment.Text = myCurrentOfferDetail.Artikeltext;
            }
        }
 public int makeOffer(OfferDetail offerDetail)
 {
     try
     {
         offerDetail.OfferDate   = DateTime.Now;
         offerDetail.OfferStatus = 0;
         context.OfferDetail.Add(offerDetail);
         context.SaveChanges();
         return(offerDetail.OfferDetalId);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void ConfigureForm()
 {
     LoadOffersType();
     if (IsNewRecord)
     {
         currentOffer  = Offer.CreateOffer();
         currentDetail = OfferDetail.CreateDetail();
         CleanControls();
     }
     else
     {
         LoadOffer();
         CalculateProductsDiscount();
     }
     ConfigureBindingList();
     ConfigureProductsList();
 }
Beispiel #15
0
 public bool SaveItemSpecificOfferDetails(OfferModel offerDetails)
 {
     try
     {
         if (offerDetails.Id > 0)
         {
             var   offer    = _couponManagmentRepository.GetOffers(offerDetails.CompanyCode, offerDetails.BranchCode).FirstOrDefault(x => x.Id == offerDetails.Id);
             Offer objOffer = new Offer();
             List <OfferDetail> lstItemSpecificCoupons = new List <OfferDetail>();
             SetOfferValuesBeforeSave(offerDetails, offer);
             int OfferId = _couponManagmentRepository.SaveOfferDetails(offer);
             //OfferDetail objOfferDetail = new OfferDetail();
             //SetItemSpecificOfferDetails(offerDetails, objOfferDetail, OfferId, ref lstItemSpecificCoupons);
             //_couponManagmentRepository.SaveItemSpecificOfferDetails(lstItemSpecificCoupons);
             List <OfferDetail> updateOfferDetail = new List <OfferDetail>();
             offerDetails.ItemSpecficOfferDetails?.ForEach(x =>
             {
                 if (x.Id > 0)
                 {
                     OfferDetail offerDetail = _couponManagmentRepository.GetOfferDetail(x.Id);
                     offerDetail.ProductCode = x.ProductCode;
                     offerDetail.Discount    = x.Discount; offerDetail.FromDate = x.FromDate; offerDetail.ToDate = x.ToDate; offerDetail.DiscountType = x.DiscountType;
                     updateOfferDetail.Add(offerDetail);
                 }
             });
             _couponManagmentRepository.SaveItemSpecificOfferDetails(updateOfferDetail);
         }
         else
         {
             Offer objOffer = new Offer();
             SetOfferValuesBeforeSave(offerDetails, objOffer);
             List <OfferDetail> lstItemSpecificCoupons = new List <OfferDetail>();
             OfferDetail        objOfferDetail         = new OfferDetail();
             int OfferId = _couponManagmentRepository.SaveOfferDetails(objOffer);
             SetItemSpecificOfferDetails(offerDetails, objOfferDetail, OfferId, ref lstItemSpecificCoupons);
             _couponManagmentRepository.SaveItemSpecificOfferDetails(lstItemSpecificCoupons);
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #16
0
 private void SetItemSpecificOfferDetails(OfferModel offerDetails, OfferDetail objOfferDetail, int OfferId, ref List <OfferDetail> lstItemSpecificCoupons)
 {
     foreach (OfferdetailModel item in offerDetails.ItemSpecficOfferDetails)
     {
         objOfferDetail = new OfferDetail();
         if (item.Id > 0)
         {
             objOfferDetail.Id = item.Id;
         }
         objOfferDetail.CreatedDate  = offerDetails.CreatedDate;
         objOfferDetail.Discount     = item.Discount;
         objOfferDetail.DiscountType = item.DiscountType;
         objOfferDetail.FromDate     = item.FromDate;
         objOfferDetail.OfferCode    = OfferId;
         objOfferDetail.ProductCode  = item.ProductCode;
         objOfferDetail.ToDate       = item.ToDate;
         lstItemSpecificCoupons.Add(objOfferDetail);
     }
 }
Beispiel #17
0
        public bool CreateOffer(int referenceA, int referenceB)
        {
            string emailAddress = HttpContext.Current.User.Identity.Name.ToString();

            if (!global.IsUniqueEmailAddress(emailAddress))
            {
                Account userAccount = global.GetAccount(emailAddress);
                try
                {
                    Item receiverItem = db.Item.Where(i => i.ItemId == referenceA).FirstOrDefault();
                    Item senderItem   = db.Item.Where(i => i.ItemId == referenceB && i.AccountId == userAccount.AccountId).FirstOrDefault();
                    if (receiverItem != null && senderItem != null)
                    {
                        Offer newOffer = new Offer();
                        newOffer.AccountId      = userAccount.AccountId;
                        newOffer.SenderItemId   = senderItem.ItemId;
                        newOffer.ReceiverId     = receiverItem.AccountId;
                        newOffer.ReceiverItemId = receiverItem.ItemId;
                        db.Offer.Add(newOffer);
                        db.SaveChanges();

                        OfferDetail newDetail = new OfferDetail();
                        newDetail.OfferId        = newOffer.OfferId;
                        newDetail.Confirmed      = 0;
                        newDetail.UploadDate     = DateTime.Now;
                        newDetail.ExpirationDate = DateTime.Now.AddDays(14);
                        db.OfferDetail.Add(newDetail);
                        db.SaveChanges();

                        RedirectViewModel redirectSender   = new RedirectViewModel("Index", "Trades", "");
                        RedirectViewModel redirectReceiver = new RedirectViewModel("UserOffers", "Trades", "");
                        SaveNotification(newOffer, redirectSender, NotificationType.AddTradeSender);
                        SaveNotification(newOffer, redirectReceiver, NotificationType.AddTradeReceiver);
                        return(true);
                    }
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }
        private void OpenSearchProductsForm()
        {
            var form = new SearchProductForm();

            form.ShowDialog();
            if (form.IsFound)
            {
                currentDetail             = OfferDetail.CreateDetail();
                currentDetail.ProductId   = form.ProductFound.ProductId;
                currentDetail.ProductName = form.ProductFound.ProductName;
                currentDetail.ActualValue = form.ProductFound.ProductValue;
                currentDetail.Percent     = $"{DiscountNumericUpDown.Value.ToString()}%";
                currentDetail.OfferValue  = form.ProductFound.ProductValue - form.ProductFound.ProductValue *
                                            float.Parse(DiscountNumericUpDown.Value.ToString()) / 100;
                currentOffer.Details.Add(currentDetail);
            }
            ConfigureBindingList();
            ConfigureProductsList();
        }
        public List <OfferDetail> GetAllCompanyOfferDetails(Customer customer)
        {
            // var _customer = _customerService.CreateCustomer(customer);
            CustomerModel requestModel = new CustomerModel
            {
                PlateNumber            = customer.PlateNumber,
                SerialCode             = customer.SerialCode,
                SerialNumber           = customer.SerialNumber,
                UniqueIdentifierNumber = customer.UniqueIdentifierNumber
            };

            List <OfferDetail> offerDetails = new List <OfferDetail>();
            var companies = _companyService.GetCompanies();

            foreach (var item in companies)
            {
                string url        = item.ServiceUrl;
                var    postResult = _apiService.PostMethod <OfferModel>(requestModel, url);

                if (postResult != null && postResult.CompanyId > 0)
                {
                    var responseDetail = new OfferDetail
                    {
                        CompanyId   = postResult.CompanyId,
                        CustomerId  = customer.Id,
                        Price       = postResult.Price,
                        Description = postResult.Description,
                    };


                    responseDetail.Customer = customer;
                    responseDetail.Company  = _companyService.GetCompany(postResult.CompanyId);
                    _offerDetailRepository.Add(responseDetail);
                    _unitOfWork.Commit();

                    offerDetails.Add(responseDetail);
                }
            }


            return(offerDetails);
        }
Beispiel #20
0
        public bool isConfirmedItem(Item item)
        {
            List <Offer> checkOffers = db.Offer.Where(o => o.SenderItemId == item.ItemId || o.ReceiverItemId == item.ItemId).ToList();

            if (checkOffers != null)
            {
                foreach (Offer offer in checkOffers)
                {
                    OfferDetail checkDetails = db.OfferDetail.Where(od => od.OfferId == offer.OfferId).FirstOrDefault();
                    if (checkDetails != null)
                    {
                        if (checkDetails.Confirmed > 0)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #21
0
        public Offer GetAcibademOffer(Customer customer)
        {
            //Şirket bilgisi getir
            var company = _companyBusiness.GetCompany(3);

            //Teklif tutarı hesapla
            var offerDetail = new OfferDetail();
            int x           = new Random().Next(200, 700);

            offerDetail.Price = 1000 + x;

            //Teklifi doldur
            var offer = new Offer();

            offer.Description      = "Acıbadem Sigorta Kasko Teklifi";
            offer.CustomerTcNumber = customer.TCNumber;
            offer.CompanyId        = company.Id;
            offer.OfferDetail      = offerDetail;

            return(offer);
        }
Beispiel #22
0
 public async Task <dynamic> AddDetailsAsync(OfferDetail item)
 {
     return(await _offerRepository.AddDetailsAsync(item));
 }
Beispiel #23
0
        public bool ConfirmOffer(int referenceA, int referenceB, out string outputMessage)
        {
            Offer referenceOffer = db.Offer.Where(o => o.ReceiverItemId == referenceA && o.SenderItemId == referenceB).FirstOrDefault();

            if (referenceOffer != null)
            {
                OfferDetail referenceDetail = db.OfferDetail.Where(od => od.OfferId == referenceOffer.OfferId).FirstOrDefault();
                if (referenceDetail != null)
                {
                    try
                    {
                        ItemDetail receiverDetail = db.ItemDetail.Where(id => id.ItemId == referenceOffer.ReceiverItemId).FirstOrDefault();
                        ItemDetail senderDetail   = db.ItemDetail.Where(id => id.ItemId == referenceOffer.SenderItemId).FirstOrDefault();
                        if (receiverDetail != null && senderDetail != null)
                        {
                            receiverDetail.ItemStatus = (int)ItemStatusType.Confirmed;
                            senderDetail.ItemStatus   = (int)ItemStatusType.Confirmed;
                            db.SaveChanges();
                        }
                        referenceDetail.ExpirationDate = DateTime.Now.AddDays(14);
                        referenceDetail.Confirmed      = 1;
                        db.SaveChanges();

                        List <Offer> referenceOffers = db.Offer.Where(o => o.ReceiverItemId == referenceA).ToList();
                        if (referenceOffers != null)
                        {
                            foreach (Offer offer in referenceOffers)
                            {
                                OfferDetail offerDetail = db.OfferDetail.Where(od => od.OfferId == offer.OfferId && od.Confirmed == 0).FirstOrDefault();
                                if (offerDetail != null)
                                {
                                    db.OfferDetail.Remove(offerDetail);
                                    RedirectViewModel redirectSenderReject = new RedirectViewModel("Index", "Trades", "");
                                    SaveNotification(offer, redirectSenderReject, NotificationType.DeleteTradeSender);
                                    db.Offer.Remove(offer);
                                    db.SaveChanges();
                                }
                            }
                        }

                        List <Wishlist> referenceWishlists = db.Wishlist.Where(w => w.ItemId == referenceOffer.ReceiverItemId || w.ItemId == referenceOffer.SenderItemId).ToList();
                        if (referenceWishlists != null)
                        {
                            db.Wishlist.RemoveRange(referenceWishlists);
                            db.SaveChanges();
                        }

                        RedirectViewModel redirectSender   = new RedirectViewModel("Index", "Trades", "");
                        RedirectViewModel redirectReceiver = new RedirectViewModel("UserOffers", "Trades", "");
                        SaveNotification(referenceOffer, redirectSender, NotificationType.ConfirmTradeSender);
                        SaveNotification(referenceOffer, redirectReceiver, NotificationType.ConfirmTradeReceiver);
                    }
                    catch
                    {
                        outputMessage = Resources.Processing.ProcessError;
                        return(false);
                    }
                    outputMessage = "Offer has been confirmed.";
                    return(true);
                }
            }
            outputMessage = Resources.Processing.ProcessError;
            return(false);
        }
Beispiel #24
0
        public IActionResult MakeOffer(OfferDetail offerdetail)
        {
            var product = shopContext.makeOffer(offerdetail);

            return(Ok(product));
        }
 public int makeOffer(OfferDetail offerDetail)
 {
     return(sellRepository.makeOffer(offerDetail));
 }
 public void CreateOfferDetail(OfferDetail offerDetail)
 {
     _offerDetailRepository.Add(offerDetail);
     SaveCustomer();
 }
 public int makeOffer(OfferDetail offerDetail)
 {
     throw new NotImplementedException();
 }