public int Add(GuideDto dto) { var model = Mapper.Map <TGuide>(dto); var data = _despository.Insert(model); return(data); }
public IActionResult CreateTour([FromBody] GuideDto guide) { var guideMapped = _mapper.Map <Guide>(guide); _uow.Guides.Create(guideMapped); return(Ok()); }
public ActionResult AddNewGuide(GuideDto newGuide) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_Guides guide = new T_Guides { GuideName = newGuide.GuideName, Tel = newGuide.Tel, Contact = newGuide.Contact, LandFee = newGuide.LandFee, AgentLandFee = newGuide.AgentLandFee, SeaFee = newGuide.SeaFee, AgentSeaFee = newGuide.AgentSeaFee, Remark = newGuide.Remark, SupplierID = newGuide.SupplierID }; db.T_Guides.Add(guide); db.SaveChanges(); result.Code = SystemConst.MSG_SUCCESS; } catch (Exception exception) { result.Message = exception.Message; } return(Content(AppUtils.JsonSerializer(result))); } }
public ActionResult ModifyGuide(GuideDto guide) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_Guides theGuide = db.T_Guides.FirstOrDefault(a => a.GuideID == guide.GuideID); theGuide.Tel = guide.Tel; theGuide.Contact = guide.Contact; theGuide.LandFee = guide.LandFee; theGuide.SeaFee = guide.SeaFee; theGuide.AgentLandFee = guide.AgentLandFee; theGuide.AgentSeaFee = guide.AgentSeaFee; theGuide.Remark = guide.Remark; theGuide.SupplierID = guide.SupplierID; db.T_Guides.Attach(theGuide); db.Entry(theGuide).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); result.Code = SystemConst.MSG_SUCCESS; } catch (Exception exception) { result.Message = exception.Message; } return(Content(AppUtils.JsonSerializer(result))); } }
private static GuideCommand ToCommand(this GuideDto guide) { return(new GuideCommand { Body = guide.Body }); }
public void AddTest() { var dto = new GuideDto { Id = Guid.NewGuid().ToString().Remove(2, 7), Name = "jjjjjjjjjjjj", Mobile = "15988888888", Certificate = "345334.url", Headpic = "http://wwes.ssr" }; Print(_guide.Add(dto)); }
//metoda zworcenia pojedynczego poradnika public async Task <ResultDto <GuideDto> > GetGuide(int id) { var result = new ResultDto <GuideDto>() { Error = null }; //sprawdzam czy poradnik istnieje var guide = await _guideRepo.GetSingleEntity(x => x.Id == id); if (guide == null) { result.Error = "Nie odnaleziono poradnika"; return(result); } //sprawdzam czy uzytkownik istnieje var user = await _userRepo.GetSingleEntity(x => x.Id == guide.AuthorId); if (user == null) { result.Error = "Nie odnaleziono autora"; return(result); } //sprawdzam czy gra istnieje var game = await _gameRepo.GetSingleEntity(x => x.Id == guide.GameId); if (game == null) { result.Error = "Nie odnaleziono gry"; return(result); } //zwracam poradnik var guideToSend = new GuideDto() { Id = guide.Id, Content = guide.Content, Username = user.Username, Name = guide.Name, GameName = game.Name, GameImage = game.Image, Rating = guide.Rating }; result.SuccessResult = guideToSend; return(result); }
public AddGuide(GuideDto guide) { InitializeComponent(); selectedGuide = guide; txtGuideName.Text = guide.GuideName; txtGuideName.Enabled = false; txtTel.Text = guide.Tel; txtContact.Text = guide.Contact; txtLandFee.Text = guide.LandFee.ToString(); txtSeaFee.Text = guide.SeaFee.ToString(); txtAgentLandFee.Text = guide.AgentLandFee.ToString(); txtAgentSeaFee.Text = guide.AgentSeaFee.ToString(); txtRemark.Text = guide.Remark; supplierID = guide.SupplierID; isModify = true; }
private void modifyGuide() { if (dgGuides.SelectedCells.Count == 0) { MessageBox.Show(LangBase.GetString("NOT_SELECT_GUIDE")); return; } else { int rowIndex = dgGuides.SelectedCells[0].RowIndex; GuideDto travelProject = guides[rowIndex]; AddGuide modifyTravelProject = new AddGuide(travelProject); if (modifyTravelProject.ShowDialog() == DialogResult.OK) { GetAllGuides(); } } }
private void btnOK_Click(object sender, EventArgs e) { if (!ClientUtils.CheckEmpty(txtGuideName, "EMPTY_GUIDE_NAME") || !ClientUtils.CheckEmpty(txtLandFee, "EMPTY_LAND_FEE") || !ClientUtils.CheckEmpty(txtSeaFee, "EMPTY_SEA_FEE") || !ClientUtils.CheckEmpty(txtAgentLandFee, "EMPTY_AGENT_LAND_FEE") || !ClientUtils.CheckEmpty(txtAgentSeaFee, "EMPTY_AGENT_SEA_FEE")) { return; } int guideID = selectedGuide == null ? 0 : selectedGuide.GuideID; GuideDto param = new GuideDto { GuideID = guideID, GuideName = txtGuideName.Text, Tel = txtTel.Text, Contact = txtContact.Text, LandFee = Convert.ToSingle(txtLandFee.Text), AgentLandFee = Convert.ToSingle(txtAgentLandFee.Text), SeaFee = Convert.ToSingle(txtSeaFee.Text), AgentSeaFee = Convert.ToSingle(txtAgentSeaFee.Text), Remark = txtRemark.Text, SupplierID = supplierID }; string strResult = WebCall.PostMethod <GuideDto>(isModify ? WebCall.ModifyGuides: WebCall.AddGuides, param); WebResult result = AppUtils.JsonDeserialize <WebResult>(strResult); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { ClientUtils.WarningCode(Travel.Client.Lang.LangBase.GetString(isModify ? "MODIFY_SUCCESS" : "ADD_SUCCESS") + result.Message); this.DialogResult = DialogResult.OK; this.Close(); } else { ClientUtils.WarningCode(result.Message); } }
public ActionResult <int> Post([FromBody] GuideDto dto) { return(_guide.Add(dto)); }
//metoda pobrania wielu poradników public async Task <ResultDto <GuidesDto> > GetGuides(int userId, int gameId) { var result = new ResultDto <GuidesDto>() { Error = null }; List <GuideDto> list = new List <GuideDto>(); List <Guide> guides = new List <Guide>(); //jesli niesprecyzowano uzytkownika lub gry, zwraca wszystkie poradniki, jesli jednak podano jedna lub obie dane //wyszukiwane są poradniki spelniajace ten warunek lub warunki if (userId == 0 && gameId == 0) { guides = await _guideRepo.GetAll(); } else if (userId != 0) { var user = _userRepo.GetSingleEntity(x => x.Id == userId); if (user == null) { result.Error = "Nie znaleziono użytkownika"; return(result); } guides = await _guideRepo.GetAllBy(x => x.AuthorId == userId); if (gameId != 0) { guides = guides.Where(x => x.GameId == gameId).ToList(); } } else { var game = _gameRepo.GetSingleEntity(x => x.Id == gameId); if (game == null) { result.Error = "Nie znaleziono gry"; return(result); } guides = await _guideRepo.GetAllBy(x => x.GameId == gameId); } //z uzyskanej listy poradnikow tworzona jest lista do przeslania foreach (var guide in guides) { var user = await _userRepo.GetSingleEntity(x => x.Id == guide.AuthorId); var game = await _gameRepo.GetSingleEntity(x => x.Id == guide.GameId); var review = await _reviewRepo.GetSingleEntity(x => x.UserId == user.Id && x.GuideId == guide.Id); int rating; if (review == null) { rating = 0; } else { rating = review.Rating; } var reviews = await _reviewRepo.GetAllBy(x => x.GuideId == guide.Id); var g = new GuideDto() { Id = guide.Id, Content = guide.Content, Username = user.Username, Name = guide.Name, GameName = game.Name, GameImage = game.Image, Rating = guide.Rating, UserRating = rating, ReviewCount = reviews.Count, Created = guide.Created.ToString() }; list.Add(g); } result.SuccessResult = new GuidesDto() { Guides = list }; return(result); }