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()); }
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); } }
public IHttpActionResult AddAuction(AuctionDTO auction) { Auction a = AuctionDTO.GetAuctionByAuctionDTO(auction); ServiceLocator.GetInstance.GetAuctionService.Save(a); return(this.Ok()); }
/// <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); }
public void Save(Auction auction) { var snapshot = auction.GetSnapshot(); var auctionDTO = new AuctionDTO(); Map(auctionDTO, snapshot); _unitOfWork.RegisterAmended(auctionDTO, this); }
public void Add(Auction auction) { var snapshot = auction.GetSnapshot(); var auctionDTO = new AuctionDTO(); Map(auctionDTO, snapshot); _unitOfWork.RegisterNew(auctionDTO, this); }
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); }
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); } }
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))); }
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); }
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; } }
/// <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; } }
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); } }
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); }
/// <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)); }
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")); }
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()); }
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); }
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); }
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); } }
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); } }
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)); }
internal Auction ConvertAuction(AuctionDTO auction) { return(new Auction(auction.AuctionId, auction.DateCreated, auction.Sold, auction.EndDateTime, auction.MinPrice, auction.BuyoutPrice, auction.ItemId)); }
public AuctionDTO GetAuction(int id) { return(AuctionDTO.GetAuctionDtoByAuction(ServiceLocator.GetInstance.GetAuctionService.GetById(id))); }
/// <summary> /// /// </summary> /// <param name="newItem"></param> /// <returns></returns> public async Task <AuctionDTO> UpdateAuctionAsync(AuctionDTO newItem) { await Task.Delay(-1); return(null); }
public void CreateAuction(AuctionDTO auction) { throw new NotImplementedException(); }