public int AgregaSorteo() { try { Premio = new PremioDTO(); Cliente = new ClientesDTO(); Voucher = new VoucherDTO(); Premio.IdPremio = this.premioid; Cliente.Clienteid = this.clienteid; Voucher.IdVoucher = this.voucherid; if (Premio.GetPremioByID() && Cliente.GetClientByID() && (Voucher.GetVoucherById() == 0)) { SorteoDTO sorteo = new SorteoDTO(); sorteo.Clienteid = this.clienteid; sorteo.IdPremio = this.premioid; sorteo.IdVoucher = this.voucherid; this.IdSorteo = sorteo.addSorteo(); if (this.IdSorteo != -1) { return(IdSorteo); } } } catch (Exception ex) { return(-1); } return(-1); }
private void lueVoucher_EditValueChanged(object sender, EventArgs e) { if (lueVoucher.EditValue != null) { Voucher_MaVoucher = (int)(lueVoucher.EditValue); VoucherDTO vou = (VoucherDTO)lueVoucher.GetSelectedDataRow(); Voucher_TiLe = vou.TiLe / 100; // if (lvDSGhe.SelectedItems.Count == 0) // { // lbTheLoai.Text = "Chưa chọn Ghế"; // } if (lsVeChon.Count > 0) { tongtien = 0; foreach (VeDTO ve in lsVeChon) { if (GiaGoc > ve.GiaVe) { ve.GiaVe = GiaGoc; } else { GiaGoc = ve.GiaVe; } ve.GiaVe -= int.Parse((ve.GiaVe * Voucher_TiLe).ToString()); tongtien += ve.GiaVe; } lbTongThanhToan.Text = tongtien + "đ"; } } }
public ActionResult <VoucherDTO> Put([FromBody] VoucherDTO voucherDto) { try { if (!ModelState.IsValid) { _logger.LogError("Invalid model state."); return(BadRequest()); } else { var voucher = _mapper.Map <Voucher>(voucherDto); _voucherRepo.UpdateVoucher(voucher); _voucherRepo.Save(); return(Ok(voucherDto)); } } catch (Exception e) { _logger.LogError("Exception occurred while attempting to update a Voucher.\nError: " + e.Message); return(BadRequest()); } }
public List <VoucherDTO> LoadVoucher(int MaTV) { SqlConnection conn = DataProvider.TaoKetNoi(); string strTruyVan = "Select * From Voucher_ThanhVien, Voucher where Voucher_ThanhVien.MaVoucher = Voucher.MaVoucher AND Voucher_ThanhVien.MaTV = @MaTV AND Voucher.TrangThai = 1"; SqlParameter[] par = new SqlParameter[1]; par[0] = new SqlParameter("@MaTV", MaTV); SqlDataReader sdr = DataProvider.TruyVanDuLieu(strTruyVan, par, conn); List <VoucherDTO> ls = new List <VoucherDTO>(); while (sdr.Read()) { VoucherDTO ketqua = new VoucherDTO(); ketqua.MaVoucher = int.Parse(sdr["MaVoucher"].ToString()); ketqua.MaTV = int.Parse(sdr["MaTV"].ToString()); ketqua.TenVoucher = sdr["TenVoucher"].ToString(); ketqua.TiLe = float.Parse(sdr["TiLe"].ToString()); ketqua.NgayDung = sdr["NgayDung"].ToString(); ketqua.HanSuDung = DateTime.Parse(sdr["HanSuDung"].ToString()); ketqua.TrangThai = int.Parse(sdr["TrangThai"].ToString()); ls.Add(ketqua); } sdr.Close(); conn.Close(); return(ls); }
public ActionResult <VoucherDTO> Post([FromBody] VoucherDTO voucherDto) { try { if (!ModelState.IsValid) { _logger.LogError("Invalid model state."); return(BadRequest()); } else { var voucher = _mapper.Map <Voucher>(voucherDto); _voucherRepo.AddVoucher(voucher); _voucherRepo.Save(); return(Created($"/api/Vouchers/{voucher.VoucherId}", voucherDto)); } } catch (Exception e) { _logger.LogError("Exception occurred while attempting to add a Voucher.\nError: " + e.Message); return(BadRequest()); } }
} // 1 = usado //retorna 0 si el codigo promocional existe disponible y lo carga en el objeto //retorna 1 si el codigo promocional ya ha sido utilizado y lo carga en el objeto //retorna 2 si el codigo promocional no existe carga objeto en 0 // retorna -1 error base o de logica public int ValidoCodigo() { if (this.CodigoPromocional == "") { return(-1); } try { VoucherDTO voucher = new VoucherDTO(); voucher.CodigoPromocional = this.CodigoPromocional; int aux = voucher.GetVoucherByCode(); if (aux == 0 || aux == 1) { this.IdVoucher = voucher.IdVoucher; this.CodigoPromocional = voucher.CodigoPromocional; this.Estado = voucher.Estado; } return(aux); } catch (Exception ex) { return(-1); } }
public IHttpActionResult Put(Guid id, [FromBody] VoucherDTO value) { if (id == Guid.Empty) { return(BadRequest("id is empty")); } var voucher = UnitOfWork.VouchersRepository.Find(id); if (voucher == null) { return(NotFound()); } voucher.Title = value.Title; voucher.Code = value.Code; voucher.Period = value.Period; voucher.OrganisationId = Guid.Parse(value.Organisation.Id); voucher.IsRedeemed = value.IsRedeemed; try { UnitOfWork.VouchersRepository.InsertOrUpdate(voucher); UnitOfWork.Save(); MemoryCacher.DeleteListAndItem(CACHE_KEY, id); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public ActionResult UpdateVoucher(VoucherDTO vhr) { var c = posMasters.UpdateVoucher(vhr); return(new JsonResult { Data = c, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public ActionResult DeleteVoucher(VoucherDTO Vch) { var c = posMasters.DeleteVoucher(Vch.VoucherId); return(new JsonResult { Data = c, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <ActionResult <Voucher> > PostVoucher(VoucherDTO voucher) { VoucherCreate voucherCreate = new VoucherCreate { voucherDTO = voucher }; return(await voucherCreate.Excute()); }
public async Task <IActionResult> PutVoucher(VoucherDTO voucherDTO) { VoucherUpdate voucherUpdate = new VoucherUpdate { voucherDTO = voucherDTO }; return(await voucherUpdate.Excute()); }
public Voucher updateVoucher(Voucher voucher, VoucherDTO voucherDTO) { voucher.VoucherID = voucherDTO.VoucherID; voucher.Amount = voucherDTO.Amount; voucher.Code = voucherDTO.Code; voucher.DateIssued = voucherDTO.DateIssued; voucher.Valid = voucherDTO.Valid; return(voucher); }
private void LoadVC() { VoucherDTO vc = VoucherDAO.Instance.GETDTOVoucher(_maVC); txbVoucher.Text = _maVC; txbGiamGiaPT.Text = vc.GiamGia.ToString(); txbGiamGiaTM.Text = vc.GiamTien.ToString(); txbNoiDung.Text = vc.TenVoucher; dtpkHSD.Value = vc.HanSuDung; }
public VoucherDTO GETDTOVoucher(string maVC) { DataTable data = DataProvider.Instance.ExecuteQuery("Select * From Voucher WHERE id = '" + maVC + "'"); if (data.Rows.Count > 0) { VoucherDTO km = new VoucherDTO(data.Rows[0]); return(km); } return(null); }
public async Task <ResponseResult> AplicarVoucherCarrinho(VoucherDTO voucher) { var itemContent = ObterConteudo(voucher); var response = await _httpClient.PostAsync("/carrinho/aplicar-voucher/", itemContent); if (!TratarErrosResponse(response)) { return(await DeserializarObjetoResponse <ResponseResult>(response)); } return(RetornoOk()); }
private Voucher convertDtoToObject(VoucherDTO voucherDTO) { Voucher tempVoucher = new Voucher(); tempVoucher.VoucherID = voucherDTO.VoucherID; tempVoucher.Amount = voucherDTO.Amount; tempVoucher.Code = voucherDTO.Code; tempVoucher.DateIssued = voucherDTO.DateIssued; tempVoucher.Valid = voucherDTO.Valid; return(tempVoucher); }
public async Task <ResponseResult> AddVoucherToCart(VoucherDTO voucher) { var itemContent = GetContent(voucher); var response = await _httpClient.PostAsync($"/api/cart/add-voucher", itemContent); if (!TreateErrorsResponse(response)) { return(await DeserializeObjectResponse <ResponseResult>(response)); } return(ReturnOk()); }
public VouchersController(VoucherInterface voucherRepo, VoucherService voucherService) { this.voucherService = voucherService; this.voucherRepo = voucherRepo; IEnumerable someVoucher = voucherRepo.GetAll(); newVouchers = new List <VoucherDTO>(); foreach (Voucher i in someVoucher) { VoucherDTO newVoucher = new VoucherDTO(i); newVouchers.Add(newVoucher); } }
public List <VoucherDTO> GetlistVC() { List <VoucherDTO> listVC = new List <VoucherDTO>(); string query = "Select * From Voucher "; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { VoucherDTO vc = new VoucherDTO(item); listVC.Add(vc); } return(listVC); }
public async Task <ResponseErrorResult> ApplyVoucherCart(VoucherDTO voucher) { var itemContent = GetContent(voucher); var response = await _httpClient.PostAsync("/cart/apply-voucher/", itemContent); if (!CheckErrorsResponse(response)) { return(await DeserializeObjectResponse <ResponseErrorResult>(response)); } return(ReturnOk()); }
public async Task <ResponseResult> ApplyVoucherOnShopCart(VoucherDTO voucher) { var itemContent = GetContent(voucher); var response = await _httpClient.PostAsync("/shopCart/appy-voucher", itemContent); if (!HandlingErrorsReponse(response)) { return(await DeserializeObjectResponse <ResponseResult>(response)); } return(ReturnOk()); }
// GET api/vouchers/id public VoucherDTO GetById(int id) { //Have to do some error handling here if id doesnt exist Voucher someVoucher = voucherRepo.GetById(id); if (someVoucher == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } VoucherDTO someVoucherDTO = new VoucherDTO(someVoucher); return(someVoucherDTO); }
public List <VoucherDTO> LayThongTinVoucher(string maVC) { List <VoucherDTO> listVC = new List <VoucherDTO>(); string query = "Select * From Voucher where id = '" + maVC + "'"; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { VoucherDTO vc = new VoucherDTO(item); listVC.Add(vc); } return(listVC); }
// PUT api/vouchers/id ~ Works public VoucherDTO PutVoucher(VoucherDTO item) { Voucher voucherItem = voucherRepo.GetById(item.VoucherID); if (voucherItem == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } var voucherItemUpdate = updateVoucher(voucherItem, item); voucherRepo.Update(voucherItemUpdate); return(item); }
public ActionResult SaveVoucher(VoucherDTO vhr) { vhr.statusid = 1; vhr.createdby = Convert.ToInt64(Session["UserId"]); if (string.IsNullOrEmpty(vhr.ValidPeriod)) { vhr.ValidPeriod = "0"; } if (string.IsNullOrEmpty(vhr.ValidUpto)) { vhr.ValidUpto = "01-01-0001"; } var c = posMasters.SaveVoucher(vhr); return(new JsonResult { Data = c, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public VoucherDTO getEditDataVoucher(int idVoucher) { using (var sqlConnection = new SqlConnection(conexion)) { VoucherDTO voucherDTO = new VoucherDTO(); string sqlGetVoucher = " select tv.idVoucher,tv.serieVoucher,tv.gloss,tv.dateVoucher,tv.tc,tv.statusVoucher,tv.typeVoucher,tv.idUser,tv.idCurrency,tv.idCompany,tc.nameCurrency " + " from tblVoucher tv,tblCurrency tc " + " where tv.idCurrency =tc.idCurrency and idVoucher = " + idVoucher; voucherDTO.voucher = sqlConnection.Query <Voucher>(sqlGetVoucher, commandType: System.Data.CommandType.Text).FirstOrDefault(); string sqlGetVoucherDetail = "select tv.idVoucherDetail,concat(ta.codeAccount,'-',ta.nameAccount) as account,tv.gloss,tv.amountOwed,tv.amountAssets,tv.amountOwedAlt,tv.amountAssetsAlt,ta.idAccount,tv.idVoucher " + " from tblVoucherDetail tv,tblAccounts ta" + " where tv.idAccount = ta.idAccount and tv.idVoucher =" + idVoucher; voucherDTO.voucherDetail = sqlConnection.Query <VoucherDetail>(sqlGetVoucherDetail, commandType: System.Data.CommandType.Text).ToList(); voucherDTO.response = new Response { Done = true, Message = "Get successfully", Value = 1 }; return(voucherDTO); } }
public IHttpActionResult Post([FromBody] VoucherDTO value) { var voucher = Mapper.Map <Voucher>(value); voucher.OrganisationId = Guid.Parse(value.Organisation.Id); voucher.Organisation = null; try { UnitOfWork.VouchersRepository.InsertOrUpdate(voucher); UnitOfWork.Save(); MemoryCacher.Delete(CACHE_KEY); return(Ok()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public Voucher AssignVoucher(VoucherDTO voucherDTO, long id) { var _context = new TGDDContext(); if (id == 0) { id = _context.Vouchers.Max(o => o.Id) + 1; } var newVoucher = new Voucher { Id = id, Code = voucherDTO.Code, DiscountPercent = voucherDTO.DiscountPercent, Name = voucherDTO.Name, StartDate = DateTime.Parse(voucherDTO.StartDate), EndDate = DateTime.Parse(voucherDTO.EndDate), }; return(newVoucher); }
public List <VoucherDTO> LoadVoucher() { SqlConnection conn = DataProvider.TaoKetNoi(); string strTruyVan = "Select * From Voucher where TrangThai=1"; SqlDataReader sdr = DataProvider.TruyVanDuLieu(strTruyVan, conn); List <VoucherDTO> ls = new List <VoucherDTO>(); while (sdr.Read()) { VoucherDTO ketqua = new VoucherDTO(); ketqua.MaVoucher = int.Parse(sdr["MaVoucher"].ToString()); ketqua.TenVoucher = sdr["TenVoucher"].ToString(); ketqua.TiLe = float.Parse(sdr["TiLe"].ToString()); ketqua.NgayDung = sdr["NgayDung"].ToString(); ketqua.HanSuDung = DateTime.Parse(sdr["HanSuDung"].ToString()); ketqua.TrangThai = int.Parse(sdr["TrangThai"].ToString()); ls.Add(ketqua); } sdr.Close(); conn.Close(); return(ls); }
public bool CambiarEstado() { if (this.CodigoPromocional == "" || !(this.IdVoucher > 0)) { return(false); } try { VoucherDTO voucher = new VoucherDTO(); voucher.IdVoucher = this.IdVoucher; voucher.CodigoPromocional = this.CodigoPromocional; bool aux = voucher.ChangeStatus(); this.Estado = voucher.Estado; return(aux); } catch (Exception ex) { return(false); } }