예제 #1
0
        public async Task <ActionResult> Put(int auctionId, AuctionDTO model)
        {
            try
            {
                var auction = await _repo.GetAuctionByIdAsync(auctionId);

                if (auction == null)
                {
                    return(NotFound());
                }

                _mapper.Map(model, auction);

                _repo.Update(auction);
                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"api/auction/{auction.Id}", _mapper.Map <AuctionDTO>(auction)));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou"));
            }

            return(BadRequest());
        }
예제 #2
0
        private async Task SendMail(AuctionDTO auctionDto, AccountDTO bidAccountDto, decimal bidValue)
        {
            var auctOwner = await accountService.GetAccountAccordingToIdAsync(auctionDto.AccountId);

            var          fromAddress  = new MailAddress("*****@*****.**", "AuctionPortal");
            var          toAddress    = new MailAddress(auctOwner.Email, auctOwner.FirstName + " " + auctOwner.LastName);
            const string fromPassword = "******";
            const string subject      = "BidOnYourAccount";
            string       body         = $"{bidAccountDto.FirstName} {bidAccountDto.LastName} just bid: {bidValue} on your auction: {auctionDto.Name}";

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            {
                smtp.Send(message);
            }
        }
예제 #3
0
        public IHttpActionResult AddAuction(AuctionDTO auction)
        {
            Auction a = AuctionDTO.GetAuctionByAuctionDTO(auction);

            ServiceLocator.GetInstance.GetAuctionService.Save(a);
            return(this.Ok());
        }
예제 #4
0
        /// <summary>
        /// Loads the available bank accounts in the comoboxes.
        /// </summary>

        private void cboAuctions_ComboSelectAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            try
            {
                if (!string.IsNullOrEmpty(CboAuctions.Value))
                {
                    mObjLastAuction = mAuctionDAO.GetAuctionByFolio(CboAuctions.Value);

                    if (mObjLastAuction != null)
                    {
                        LoadSellers(mObjLastAuction.Folio);
                        mEdtFolio.Value        = mObjLastAuction.Folio;
                        lObjBtnCC.Item.Enabled = true;
                    }
                    else
                    {
                        UIApplication.ShowError("No hay subastas activas.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtility.WriteError(string.Format("[CheckGeneration - cboAuctions_ComboSelectAfter] Error: {0}", ex.Message));
                UIApplication.ShowMessageBox(ex.Message);
                //UIApplication.ShowError("frm (LoadMatrix)" + ex.Message);
            }
            finally
            {
                this.UIAPIRawForm.Freeze(false);
            }
        }
        public void Add(Auction auction)
        {
            var auctionDTO = new AuctionDTO();

            Map(auctionDTO, auction.GetSnapshot());

            _auctionExampleContext.Auctions.Add(auctionDTO);
        }
예제 #6
0
        public void Save(Auction auction)
        {
            var snapshot   = auction.GetSnapshot();
            var auctionDTO = new AuctionDTO();

            Map(auctionDTO, snapshot);

            _unitOfWork.RegisterAmended(auctionDTO, this);
        }
예제 #7
0
        public void Add(Auction auction)
        {
            var snapshot   = auction.GetSnapshot();
            var auctionDTO = new AuctionDTO();

            Map(auctionDTO, snapshot);

            _unitOfWork.RegisterNew(auctionDTO, this);
        }
예제 #8
0
        public bool CreatePayment(AuctionDTO pObjAuctionDTO, List <InvoiceDTO> pLstObjInvoice)
        {
            bool lBolIsSuccess = false;

            try
            {
                SAPbobsCOM.Payments lObjPayment = (SAPbobsCOM.Payments)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);

                lObjPayment.CardCode      = pObjAuctionDTO.CardCode;
                lObjPayment.DocObjectCode = SAPbobsCOM.BoPaymentsObjectType.bopot_IncomingPayments;
                lObjPayment.DocDate       = DateTime.Now;
                lObjPayment.DocType       = SAPbobsCOM.BoRcptTypes.rCustomer;
                lObjPayment.UserFields.Fields.Item("U_GLO_PaymentType").Value  = "GLPGO";
                lObjPayment.UserFields.Fields.Item("U_FZ_AuxiliarType").Value  = "1";
                lObjPayment.UserFields.Fields.Item("U_FZ_Auxiliar").Value      = pObjAuctionDTO.CardCode;
                lObjPayment.UserFields.Fields.Item("U_FZ_FolioAuction").Value  = pObjAuctionDTO.AuctionID;
                lObjPayment.UserFields.Fields.Item("U_GLO_CostCenter").Value   = pObjAuctionDTO.LocationId;
                lObjPayment.UserFields.Fields.Item("U_FechaPago").Value        = DateTime.Now.ToString("dd-MM-yyyy");
                lObjPayment.UserFields.Fields.Item("U_HoraPago").Value         = DateTime.Now.ToString("HH:mm");
                lObjPayment.UserFields.Fields.Item("U_B1SYS_PmntMethod").Value = "17";


                lObjPayment.CashSum = Convert.ToDouble(pObjAuctionDTO.TotalSell);

                lObjPayment.CashAccount = pObjAuctionDTO.AccountD;// lObjPurchasesDAO.GetAccountRefund(pObjPurchase.Area);



                foreach (InvoiceDTO lObjInvoice in pLstObjInvoice)
                {
                    lObjPayment.Invoices.DocEntry    = Convert.ToInt32(lObjInvoice.DocEntry);
                    lObjPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice;
                    lObjPayment.Invoices.SumApplied  = Convert.ToDouble(lObjInvoice.Amount);
                    lObjPayment.Invoices.Add();
                }


                if (lObjPayment.Add() != 0)
                {
                    UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription()));
                    LogService.WriteError("PaymentDI (CreatePayment) DocEntry:" + pObjAuctionDTO.AuctionID + " Mensaje:" + DIApplication.Company.GetLastErrorDescription());
                }
                else
                {
                    LogService.WriteSuccess("pago creado correctamente: InvoiceDocEntry: " + pObjAuctionDTO.AuctionID);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("PaymentDI (Create) InvoiceDocEntry:" + pObjAuctionDTO.AuctionID + " Mensaje:" + ex.Message);
                LogService.WriteError(ex);
            }
            return(lBolIsSuccess);
        }
예제 #9
0
        public async Task <Guid> CreateAuctionWithCategoryNameAsync(AuctionDTO auction, string categoryName)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                auction.CategoryId = (await categoryService.GetCategoryIdsByNamesAsync(categoryName)).FirstOrDefault();
                var auctionId = auctionService.Create(auction);
                await uow.Commit();

                return(auctionId);
            }
        }
예제 #10
0
        public async Task <IActionResult> Create([FromBody] AuctionDTO request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var auction = await _auctionService.InsertAuctionAsync(request, _userProvider.GetUserId(), _userProvider.GetUserRole());

            return(Ok(JsonSerializer.Serialize(auction)));
        }
예제 #11
0
        public IEnumerable <AuctionDTO> GetAllAuctions()
        {
            var auctions          = ServiceLocator.GetInstance.GetAuctionService.GetAll();
            List <AuctionDTO> res = new List <AuctionDTO>();

            foreach (Auction auction in auctions)
            {
                res.Add(AuctionDTO.GetAuctionDtoByAuction(auction));
            }

            return(res);
        }
예제 #12
0
        private static void ModifyCategories(AuctionDTO auctionDto, Auction auction)
        {
            auction.CreationTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            if (auction.Categories == null)
            {
                return;
            }

            foreach (var category in auction.Categories)
            {
                category.Auction = auction;
            }
        }
예제 #13
0
        /// <summary>
        /// Updates auction with given id.
        /// </summary>
        /// <param name="id">Id of the auction to update.</param>
        /// <param name="auction">Auction to update</param>
        /// <returns>Message describing the action result.</returns>
        public async Task <string> Put(Guid id, [FromBody] AuctionDTO auction)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            var success = await AuctionFacade.EditAuctionAsync(auction);

            if (!success)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return($"Updated auction with id: {id}");
        }
        public void Map(AuctionDTO auctionDTO, AuctionSnapshot snapshot)
        {
            auctionDTO.Id            = snapshot.Id;
            auctionDTO.StartingPrice = snapshot.StartingPrice;
            auctionDTO.AuctionEnds   = snapshot.EndsAt;
            auctionDTO.Version       = snapshot.Version;

            if (snapshot.WinningBid != null)
            {
                auctionDTO.BidderMemberId = snapshot.WinningBid.BiddersId;
                auctionDTO.CurrentPrice   = snapshot.WinningBid.CurrentPrice;
                auctionDTO.MaximumBid     = snapshot.WinningBid.BiddersMaximumBid;
                auctionDTO.TimeOfBid      = snapshot.WinningBid.TimeOfBid;
            }
        }
예제 #15
0
        public async Task <bool> EditAuctionAsync(AuctionDTO auctionDto)
        {
            using (var uow = UnitOfWorkProvider.Create())
            {
                if (await auctionService.GetAsync(auctionDto.Id, false) == null)
                {
                    return(false);
                }

                await auctionService.Update(auctionDto);

                await uow.Commit();

                return(true);
            }
        }
예제 #16
0
파일: CyCDAO.cs 프로젝트: radtek/UGRS_Full
        public List <AuctionDTO> GetAuctionDTO(string pStrFolio, string pStrCostingCode, char pCharCYC)
        {
            SAPbobsCOM.Recordset lObjRecordset  = null;
            List <AuctionDTO>    lLstAuctionDTO = new List <AuctionDTO>();

            try
            {
                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("Folio", pStrFolio);
                lLstStrParameters.Add("OcrCode", pStrCostingCode);
                lLstStrParameters.Add("CYC", pCharCYC.ToString());

                string lStrQuery = this.GetSQL("GetPayments").Inject(lLstStrParameters);
                //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery);

                lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    for (int i = 0; i < lObjRecordset.RecordCount; i++)
                    {
                        AuctionDTO lObjAuctionDTO = new AuctionDTO();
                        lObjAuctionDTO.CardCode  = lObjRecordset.Fields.Item("CardCode").Value.ToString();
                        lObjAuctionDTO.CardName  = lObjRecordset.Fields.Item("CardName").Value.ToString();
                        lObjAuctionDTO.TotalSell = lObjRecordset.Fields.Item("Venta").Value.ToString();
                        lObjAuctionDTO.TotalBuy  = lObjRecordset.Fields.Item("Invoice").Value.ToString();
                        lObjAuctionDTO.AccountD  = lObjRecordset.Fields.Item("AccountD").Value.ToString();

                        lLstAuctionDTO.Add(lObjAuctionDTO);
                        lObjRecordset.MoveNext();
                    }
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowError(string.Format("GetPayments: {0}", ex.Message));
                LogService.WriteError("PaymentDAO (GetPayments): " + ex.Message);
                LogService.WriteError(ex);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }
            return(lLstAuctionDTO);
        }
예제 #17
0
        /// <summary>
        /// This method inserts <seealso cref="AuctionDTO"/> into database
        /// </summary>
        /// <param name="auctionDto">DTO that contains valid auction information</param>
        /// <param name="userId">Id of user that creates auction</param>
        /// <param name="userRole">Role of user that creates auction</param>
        /// <returns>Result of insertion</returns>
        /// <exception cref="ValidationException">Throws when data provided in <see cref="AuctionDTO"/> not matching</exception>
        public async Task <AuctionDTO> InsertAuctionAsync(AuctionDTO auctionDto, Guid userId, string userRole)
        {
            if (auctionDto.StartTime > auctionDto.EndTime && auctionDto.AuctionType == AuctionType.Normal)
            {
                throw new ValidationException($"{nameof(auctionDto.StartTime)} can't be ahead of the {nameof(auctionDto.EndTime)}", nameof(auctionDto));
            }

            var auction = _mapper.Map <AuctionDTO, Auction>(auctionDto, opt =>
                                                            opt.AfterMap((src, dest) =>
            {
                dest.UserId = userId.ToString();
            }));

            await _unitOfWork.InsertAsync(auction);

            await _unitOfWork.CommitAsync();

            return(_mapper.Map <Auction, AuctionDTO>(auction));
        }
예제 #18
0
        public async Task <ActionResult> Create(AuctionCreateViewModel auctionViewModel)
        {
            var account = await AccountFacade.GetAccountAccordingToEmailAsync(auctionViewModel.AccountEmail);

            var category = await AuctionFacade.GetCategoryAsync(new Guid(auctionViewModel.CategoryId));

            var auctionDto = new AuctionDTO()
            {
                ClosingTime = auctionViewModel.ClosingTime,
                ActualPrice = auctionViewModel.ActualPrice,
                Name        = auctionViewModel.Name,
                Description = auctionViewModel.Description,
                AccountId   = account.Id,
                IsOpened    = true
            };
            await AuctionFacade.CreateAuctionWithCategoryNameAsync(auctionDto, category.Name);

            return(RedirectToAction("Index", "Home"));
        }
예제 #19
0
        public async Task <ActionResult> Post(AuctionDTO model)
        {
            try
            {
                var auction = _mapper.Map <Auction>(model);

                _repo.Add(auction);

                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"api/auction/{auction.Id}", _mapper.Map <AuctionDTO>(auction)));
                }
            }
            catch (System.Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco de dados falhou"));
            }

            return(BadRequest());
        }
예제 #20
0
        public IEnumerable <AuctionDTO> HotAuctions()
        {
            List <AuctionDTO> list = new List <AuctionDTO>();
            AuctionDTO        data = new AuctionDTO();

            data.Active      = true;
            data.Category    = 1;
            data.City        = "אשדוד";
            data.CreatedAt   = DateTime.Today;
            data.Creator     = "a5fj2n62kn32236mk";
            data.Description = "תיאור ניסיון";
            data.EndsAt      = DateTime.Now;
            data.Image       = "";
            data.MoneyGoal   = 500;
            data.MoneyRaised = 300;
            data.MoneyStep   = 10;
            data.Name        = "הגרלת ניסיון";
            data.Subcategory = 5;

            list.Add(data);
            return(list);
        }
예제 #21
0
        private async Task <AuctionDetailViewModel> InitializeAuctionDetailViewModel(AuctionDTO auction)
        {
            var model = new AuctionDetailViewModel {
                Name = auction.Name
            };
            var result = await AccountFacade.GetAccountAccordingToIdAsync(auction.AccountId);

            model.Bids = new List <Pair <AccountAuctionRelationDTO, AccountDTO> >();
            var bidsList = (await AuctionFacade.GetAllBidsAccordingToAuction(auction.Id)).ToList().OrderBy(x => x.BidDateTime);

            foreach (var bid in bidsList)
            {
                model.Bids.Add(new Pair <AccountAuctionRelationDTO, AccountDTO>(bid, await AccountFacade.GetAccountAccordingToIdAsync(bid.AccountId)));
            }
            model.AccountFullName = result.FirstName + " " + result.LastName;
            model.Description     = auction.Description;
            model.ClosingTime     = auction.ClosingTime;
            var products = await ProductFacade.GetAllProductsInAuction(auction.Id);

            model.Products          = products.ToList();
            model.ActualPrice       = auction.ActualPrice;
            model.IsOpened          = auction.IsOpened;
            model.Id                = auction.Id;
            model.AuctionOwnerEmail = result.Email;
            model.CategoryId        = auction.CategoryId.ToString();
            var categories = await AuctionFacade.GetAllCategories();

            model.CategoriesSelectList = new List <SelectListItem>();
            foreach (var category in categories)
            {
                model.CategoriesSelectList.Add(new SelectListItem {
                    Text = category.Name, Value = category.Id.ToString()
                });
            }


            return(model);
        }
예제 #22
0
        public AuctionDTO GetAuctionByFolio(string pStrFolio)
        {
            SAPbobsCOM.Recordset lObjResults = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            try
            {
                string lStrQuery = this.GetSQL("GetAuctionByFolio").InjectSingleValue("Folio", pStrFolio);

                lObjResults.DoQuery(lStrQuery);
                if (lObjResults.RecordCount == 0)
                {
                    return(null);
                }
                AuctionDTO lObjAuction = new AuctionDTO();
                lObjAuction.Id            = Convert.ToInt32(lObjResults.Fields.Item("U_Id").Value.ToString());
                lObjAuction.Folio         = lObjResults.Fields.Item("U_Folio").Value.ToString();
                lObjAuction.LocationId    = Convert.ToInt32(lObjResults.Fields.Item("U_LocationId").Value.ToString());
                lObjAuction.Location      = lObjResults.Fields.Item("U_Location").Value.ToString();
                lObjAuction.Type          = lObjResults.Fields.Item("U_Type").Value.ToString();
                lObjAuction.TypeId        = Convert.ToInt32(lObjResults.Fields.Item("U_TypeId").Value.ToString());
                lObjAuction.Commission    = Convert.ToDouble(lObjResults.Fields.Item("U_Commission").Value.ToString());
                lObjAuction.Date          = Convert.ToDateTime(lObjResults.Fields.Item("U_Date").Value.ToString());
                lObjAuction.AuthCorral    = lObjResults.Fields.Item("U_AutCorral").Value.ToString();
                lObjAuction.AuthTransport = lObjResults.Fields.Item("U_AutTransp").Value.ToString();
                lObjAuction.AuthTransport = lObjResults.Fields.Item("U_AutAuction").Value.ToString();
                lObjAuction.AuthCyC       = lObjResults.Fields.Item("U_AutCyC").Value.ToString();
                lObjAuction.AuthFinances  = lObjResults.Fields.Item("U_AutFz").Value.ToString();
                return(lObjAuction);
            }
            catch (Exception e)
            {
                LogUtility.WriteError(string.Format("[AuctionDAO - GetAuctionByFolio] Error al obtener la subasta con el folio {0}: {1}", pStrFolio, e.Message));
                throw new Exception(string.Format("Error al obtener la subasta con el folio {0}: {1}", pStrFolio, e.Message));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjResults);
            }
        }
예제 #23
0
 public AuctionDTO GetLastAuction()
 {
     SAPbobsCOM.Recordset lObjResults = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     try
     {
         string lStrQuery = this.GetSQL("GetLastAuction");
         lObjResults.DoQuery(lStrQuery);
         if (lObjResults.RecordCount == 0)
         {
             return(null);
         }
         AuctionDTO lObjAuction = new AuctionDTO();
         lObjAuction.Id            = lObjResults.GetColumnValue <int>("U_Id");
         lObjAuction.Folio         = lObjResults.GetColumnValue <string>("U_Folio");
         lObjAuction.LocationId    = lObjResults.GetColumnValue <int>("U_LocationId");
         lObjAuction.Location      = lObjResults.GetColumnValue <string>("U_Location");
         lObjAuction.Type          = lObjResults.GetColumnValue <string>("U_Type");
         lObjAuction.TypeId        = lObjResults.GetColumnValue <int>("U_TypeId");
         lObjAuction.Commission    = lObjResults.GetColumnValue <double>("U_Commission");
         lObjAuction.Date          = lObjResults.GetColumnValue <DateTime>("U_Date");
         lObjAuction.AuthCorral    = lObjResults.GetColumnValue <string>("U_AutCorral");
         lObjAuction.AuthTransport = lObjResults.GetColumnValue <string>("U_AutTransp");
         lObjAuction.AuthTransport = lObjResults.GetColumnValue <string>("U_AutAuction");
         lObjAuction.AuthCyC       = lObjResults.GetColumnValue <string>("U_AutCyC");
         lObjAuction.AuthFinances  = lObjResults.GetColumnValue <string>("U_AutFz");
         return(lObjAuction);
     }
     catch (Exception e)
     {
         LogUtility.WriteError(string.Format("[AuctionDAO - GetLastAuction] Error al obtener la ultima subasta: {0}", e.Message));
         throw new Exception(string.Format("Error al obtener la última subasta: {0}", e.Message));
     }
     finally
     {
         MemoryUtility.ReleaseComObject(lObjResults);
     }
 }
예제 #24
0
        public Auction GetById(int id)
        {
            AuctionDTO auction = _auctionContext.GetById(id);

            return(new Auction(auction.AuctionId, auction.DateCreated, auction.Sold, auction.EndDateTime, auction.MinPrice, auction.BuyoutPrice, auction.ItemId));
        }
예제 #25
0
 internal Auction ConvertAuction(AuctionDTO auction)
 {
     return(new Auction(auction.AuctionId, auction.DateCreated, auction.Sold, auction.EndDateTime, auction.MinPrice, auction.BuyoutPrice, auction.ItemId));
 }
예제 #26
0
 public AuctionDTO GetAuction(int id)
 {
     return(AuctionDTO.GetAuctionDtoByAuction(ServiceLocator.GetInstance.GetAuctionService.GetById(id)));
 }
예제 #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newItem"></param>
        /// <returns></returns>
        public async Task <AuctionDTO> UpdateAuctionAsync(AuctionDTO newItem)
        {
            await Task.Delay(-1);

            return(null);
        }
예제 #28
0
 public void CreateAuction(AuctionDTO auction)
 {
     throw new NotImplementedException();
 }