public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,Position,Date,Detail,picture")] Scenic scenic) { if (id != scenic.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(scenic); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScenicExists(scenic.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(scenic)); }
public async Task <IActionResult> ScenicCreate([Bind("Id,Name,Position,Date,Detail,picture")] Scenic scenic) { if (HttpContext.User.Identity.IsAuthenticated) { if (ModelState.IsValid) { scenic.Id = Guid.NewGuid(); var files = Request.Form.Files; string webRootPath = _hostingEnvironment.WebRootPath; if (files.Count > 0) { int g = files[0].FileName.LastIndexOf("."); string newFileName = scenic.Id.ToString() + files[0].FileName.Substring(g); var filePath = webRootPath + "/Images/" + newFileName; scenic.picture = "/Images/" + newFileName; using (var stream = new FileStream(filePath, FileMode.Create)) { await files[0].CopyToAsync(stream); } } _context.Add(scenic); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ScenicIndex))); } return(View(scenic)); } return(RedirectToAction("Login")); }
public ActionResult Create(Scenic model) { if (ModelState.IsValid) { _db.Scenic.Add(model); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public async Task <IActionResult> Create([Bind("Id,Name,Position,Date,Detail,picture")] Scenic scenic) { if (ModelState.IsValid) { scenic.Id = Guid.NewGuid(); _context.Add(scenic); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(scenic)); }
public ActionResult Create() { var model = new Scenic(); model.Enabled = true; var City = new Caches().TWCity; SelectList selectList = new SelectList(City, "City", "City", 0); ViewBag.City = selectList; return(View(model)); }
public async Task <bool> AddScenicSpot(Scenic scenic) { var helper = new InternetHelperForList <Scenic>(); bool r = helper.PostString(Global.url + "/AddScenic", scenic); if (r) { Global.LogServer.SaveServerLogs("新增景点" + scenic.Name + "成功"); } else { Global.LogServer.SaveServerLogs("新增景点" + scenic.Name + "失败"); } return(r); }
public bool AlterScenicSpot(Scenic scenic) { var helper = new InternetHelperForList <Scenic>(); bool r = helper.PostString(Global.url + "/AlterScenic", scenic); if (r) { Global.LogServer.SaveServerLogs("修改" + scenic.ID + ":" + scenic.Name + "景点信息成功"); } else { Global.LogServer.SaveServerLogs("修改" + scenic.ID + ":" + scenic.Name + "景点信息失败"); } return(r); }
public MyResult <object> AddScenic(ScenicDto model) { MyResult result = new MyResult(); if (string.IsNullOrEmpty(model.Pic)) { return(result.SetStatus(ErrorCode.InvalidData, "图片数据非法")); } if (string.IsNullOrEmpty(model.Title)) { return(result.SetStatus(ErrorCode.InvalidData, "标题数据非法")); } if (string.IsNullOrEmpty(model.LTitle)) { return(result.SetStatus(ErrorCode.InvalidData, "L标题数据非法")); } if (string.IsNullOrEmpty(model.Content)) { return(result.SetStatus(ErrorCode.InvalidData, "内容数据非法")); } Scenic scenic = new Scenic { Title = model.Title, Pic = model.Pic, LTitle = model.LTitle, Content = model.Content }; if (!string.IsNullOrEmpty(model.Order.ToString()) && model.Order > 0) { scenic.Order = model.Order; } if (!string.IsNullOrEmpty(model.LookCount.ToString()) && model.LookCount > 0) { scenic.LookCount = (int)model.LookCount; } if (!string.IsNullOrEmpty(model.Mark1)) { scenic.Mark1 = model.Mark1; } if (!string.IsNullOrEmpty(model.Mark2)) { scenic.Mark2 = model.Mark2; } base.Add(scenic, true); result.Data = true; return(result); }
public async Task <IActionResult> ScenicEdit(Guid id, [Bind("Id,Name,Position,Date,Detail,picture")] Scenic scenic) { if (HttpContext.User.Identity.IsAuthenticated) { if (id != scenic.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var files = Request.Form.Files; if (files.Count != 0) { string webRootPath = _hostingEnvironment.WebRootPath; int g = files[0].FileName.LastIndexOf("."); string newFileName = scenic.Id.ToString() + files[0].FileName.Substring(g); var filePath = webRootPath + "/Images/" + newFileName; scenic.picture = "/Images/" + newFileName; using (var stream = new FileStream(filePath, FileMode.Create)) { await files[0].CopyToAsync(stream); } } _context.Update(scenic); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScenicExists(scenic.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(ScenicIndex))); } return(View(scenic)); } return(RedirectToAction("Login")); }
private async Task AddScenic(MapPoint location) { var x = new Dialog_ScenicScan(); //x.Owner = Application.Current.MainWindow; x.ShowDialog(); var ScenicName = x.TxtName.Text; var ScenicDescription = x.TxtDescription.Text; var graphic = new Graphic(); //子窗体关闭按钮已做处理 if (ScenicName != string.Empty && ScenicDescription != string.Empty) { var symbol = (sceniceAgent as IRenderGraphic).CreatSymbol <CompositeSymbol>(); graphic = new Graphic { Geometry = location, Symbol = symbol }; var item = new Scenic { description = ScenicDescription, longitude = (decimal?)location.X, latitude = (decimal?)location.Y, id = Convert.ToInt32(_graphicsLayer.Graphics.Last().Attributes["ID"]) + 1, name = ScenicName }; graphic.Attributes["ID"] = item.id; graphic.Attributes["Name"] = ScenicName; graphic.Attributes["Description"] = ScenicDescription; graphic.Attributes["Longitude"] = location.X; graphic.Attributes["Latitude"] = location.Y; _graphicsLayer.Graphics.Add(graphic); var result = await sceniceAgent.AddScenicSpot(item); if (result) //新增成功 { MessageBox.Show("新增景点信息成功", "操作成功", MessageBoxButton.OK, MessageBoxImage.Information); } else { _graphicsLayer.Graphics.Remove(graphic); MessageBox.Show("新增景点信息失败", "操作失败", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public ActionResult Edit(Scenic model) { if (ModelState.IsValid) { var result = _db.Scenic.Where(o => o.ID == model.ID).FirstOrDefault(); if (result == null) { ModelState.AddModelError("", "查無資料"); return(View()); } result.Name = model.Name; result.Description = model.Description; result.Enabled = model.Enabled; _db.SaveChanges(); } return(RedirectToAction("Index")); }
/// <summary> /// 添加景点 /// </summary> /// <param name="scenic"></param> /// <returns></returns> public bool AddScenic(Scenic scenic) { InternetHelperForList <Scenic> helper = new InternetHelperForList <Scenic>(); return(helper.PostString(Global.url + "/AddScenic", scenic)); }