void ValidateRequest(ManualViewModel model) { if (String.IsNullOrEmpty(model.Title)) { ModelState.AddModelError("title", "請填寫標題"); } }
public ManuelView() { InitializeComponent(); DataContext = new ManualViewModel(); //{Binding VM_aileron} }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel( SearchViewModel searchViewModel, ManualViewModel manualViewModel, SettingsViewModel settingsViewModel, ShowTrackerViewModel showTrackerViewModel) { this.Version = ApplicationDeployment.IsNetworkDeployed ? $"ver. {ApplicationDeployment.CurrentDeployment.CurrentVersion}" : "ver. DEBUG"; this.SearchViewModel = searchViewModel; this.ManualViewModel = manualViewModel; this.SettingsViewModel = settingsViewModel; this.ShowTrackerViewModel = showTrackerViewModel; this.Width = Properties.Settings.Default.WindowWidth; this.Height = Properties.Settings.Default.WindowHeight; ListSearchCommand = new RelayCommand(OpenListSearch); InputSearchCommand = new RelayCommand(OpenInputSearch); SettingsCommand = new RelayCommand(OpenSettings); ShowTrackerCommand = new RelayCommand(OpenShowTracker); OpenListSearch(); //Default open window }
public async Task <IActionResult> Manual(String title, String userCreator) { //TODO test var manual = await _context.Manuals.FirstOrDefaultAsync(manuals => manuals.UserCreator == userCreator && manuals.Title == title); if (manual != null) { var user = await _context.Users.FirstOrDefaultAsync(us => us.UserName == userCreator); var manualViewModel = new ManualViewModel { Title = manual.Title, Body = manual.Body, Creator = manual.UserCreator, ShortDescription = manual.ShortDescription, AmountLike = manual.AmountLike, Rating = manual.Rating, Tags = GetTagsManuals(manual.Tags), ImageManual = manual.ManualImage, OtherManualsUser = user.GetUserManuals() }; return(View(manualViewModel)); } return(NotFound(title)); }
public ActionResult CreateNewManual(string ReturnUrl) { ManualViewModel model = new ManualViewModel(); ViewBag.ReturnUrl = ReturnUrl; return(View(model)); }
public Manual() { InitializeComponent(); vm = new ManualViewModel(new VirtualJoystickEventArgs()); this.DataContext = vm; InitializeComponent(); }
private void CalculateRating(ManualViewModel manual, string userId, bool liked) { Rating rating = ratingRepository.GetAll() .FirstOrDefault(e => e.UserId == userId && e.ManualId == manual.Id); if (rating == null) { ratingRepository.Add(new Rating { ManualId = manual.Id, UserId = userId, Liked = liked }); } else if (rating.Liked != liked) { if (rating.Liked == null) { rating.Liked = liked; } else { rating.Liked = null; } ratingRepository.Update(rating); } ratingRepository.Save(); }
public ActionResult Create([Bind] ManualViewModel vm) { if (ModelState.IsValid) { Manual manual = new Manual { Name = vm.Name, FileName = vm.File.FileName }; FileData data = new FileData(); using (Stream inputStream = vm.File.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } data.Data = memoryStream.ToArray(); } manual.FileData = data; db.Manuals.Add(manual); db.SaveChanges(); return(RedirectToAction("Index", "Manuals")); } return(View(vm)); }
public ManualView() { InitializeComponent(); DataContext = new ManualViewModel(); Debug.WriteLine($"Actual width: {SystemParameters.PrimaryScreenWidth}"); Debug.WriteLine($"Actual height: {SystemParameters.PrimaryScreenHeight}"); }
public ManualView() { InitializeComponent(); vm = new ManualViewModel(); this.DataContext = vm; joystick.DataContext = vm; }
public ActionResult AddComment(string content, string userId, int manualId) { Comment toAdd = new Comment() { AuthorId = userId, Content = mark.Transform(content), ManualId = manualId, VoteCount = 0, }; Manual manual = context.Manuals.Find(manualId); manual.LastUpdate = DateTime.Today; context.Comments.Add(toAdd); context.SaveChanges(); ManualViewModel model = new ManualViewModel() { Manual = manual, User = context.ApplicationUsers.Find(userId), Steps = context.Steps.Where(s => s.ManualId == manualId).ToList(), Tags = ManualHelper.GetAllManualTags(manualId, context), Comments = context.Comments.Where(c => c.ManualId == manualId).ToList(), Context = context }; return(View("Manual", model)); }
public IActionResult LikeComment(string userId, int commentId, string path) { Comment comment = context.Comments.Find(commentId); if (context.Votes.Where(c => c.CommentId == commentId && c.UserId == userId).ToList().Count == 0) { comment.VoteCount++; Vote vote = new Vote() { CommentId = commentId, UserId = userId, }; context.Votes.Add(vote); } Manual manual = context.Manuals.Find(comment.ManualId); context.SaveChanges(); ManualViewModel model = new ManualViewModel() { Manual = manual, User = context.ApplicationUsers.Find(userId), Steps = context.Steps.Where(s => s.ManualId == manual.ManualId).ToList(), Tags = ManualHelper.GetAllManualTags(manual.ManualId, context), Comments = context.Comments.Where(c => c.ManualId == manual.ManualId).ToList(), Context = context }; return(View("Manual", model)); }
private ManualViewModel manual_vm; // view model instance of manual /** * the constructor creates presentation of Manual Control based on the xaml code * and initialized his properties **/ public ManualControl() { InitializeComponent(); manual_vm = new ManualViewModel(); /* changes the data context to view model */ DataContext = manual_vm; }
public ManualPilot() { InitializeComponent(); this.vm = new ManualViewModel(); this.DataContext = vm; // Registering the Joystick_Move method to the Moved event in the Joystick. this.Joystick.Moved += this.vm.Joystick_Move; }
public Manual() { InitializeComponent(); Commands c = Commands.Instance; vm = new ManualViewModel(); DataContext = vm; }
public ActionResult ChangeRating(ManualViewModel manual, bool liked) { string currentUserId = User.Identity.GetUserId(); CalculateRating(manual, currentUserId, liked); int rating = GetRating(manual.Id); return(Json(new { newRating = rating })); }
/// <summary> /// Displays the Search View. /// </summary> private void OpenInputSearch() { IsListSearchSelected = false; IsManualSearchSelected = true; IsSettingsSelected = false; IsShowTrackerSelected = false; SelectedViewModel = ManualViewModel; ManualViewModel.OnPresented(); }
public Joystick() { InitializeComponent(); vm = ManualViewModel.Instance; Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; Moved += vm.WhenMoved; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; }
public ActionResult DeleteManual(ManualViewModel manual) { if (User.IsInRole("Admin") || manual.UserId == User.Identity.GetUserId()) { manualRepository.Delete(manual.Id); manualRepository.Save(); } return(null); }
public Joystick() { InitializeComponent(); vm = new ManualViewModel(); this.DataContext = vm; Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; }
public async Task <ActionResult> RegManual(ManualViewModel manualViewModel, IEnumerable <HttpPostedFileBase> files) { ViewBag.LeftMenu = Global.Cs; var scForm = Mapper.Map <ScForm>(manualViewModel); scForm.Status = "N"; scForm.RegDt = DateTime.Now; scForm.RegId = Session[Global.LoginID].ToString(); //첨부파일 if (files != null) { var fileHelper = new FileHelper(); foreach (var file in files) { if (file != null) { var savedFileName = fileHelper.GetUploadFileName(file); var subDirectoryPath = Path.Combine(FileType.Manual.ToString(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString()); var savedFilePath = Path.Combine(subDirectoryPath, savedFileName); var scFileInfo = new ScFileInfo { FileNm = Path.GetFileName(file.FileName), FilePath = savedFilePath, Status = "N", RegId = Session[Global.LoginID].ToString(), RegDt = DateTime.Now }; var scFormFile = new ScFormFile { ScFileInfo = scFileInfo }; scForm.ScFormFiles.Add(scFormFile); await fileHelper.UploadFile(file, subDirectoryPath, savedFileName); } } } //저장 int result = await _scFormService.AddScFormAsync(scForm); if (result != -1) { return(RedirectToAction("Manual", "Cs")); } else { ModelState.AddModelError("", "메뉴얼 등록 실패."); return(View(manualViewModel)); } }
public static Manual MapEntity(this ManualViewModel model, IMapper mapper, string currentUserId) { var entity = mapper.Map <ManualViewModel, Manual>(model); if (model.Id == 0) { entity.SetCreated(currentUserId); } entity.SetUpdated(currentUserId); entity.Content = entity.Content.ReplaceNewLine(""); return(entity); }
public Joystick() { InitializeComponent(); Knob.MouseLeftButtonDown += Knob_MouseLeftButtonDown; Knob.MouseLeftButtonUp += Knob_MouseLeftButtonUp; Knob.MouseMove += Knob_MouseMove; centerKnob = Knob.Resources["CenterKnob"] as Storyboard; vm = ManualViewModel.Instance; DataContext = vm; Moved += vm.update; Released += vm.reset; }
public ActionResult DeleteConfirmed(int id) { Manual manual = db.Manuals.Include("FileData").SingleOrDefault(x => x.Id == id); ManualViewModel vm = new ManualViewModel { Id = manual.Id, Name = manual.Name }; db.FileDatas.Remove(manual.FileData); db.Manuals.Remove(manual); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Store([FromBody] ManualViewModel model) { ValidateRequest(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } model.Order = model.Active ? 0 : -1; var manual = model.MapEntity(_mapper, CurrentUserId); manual = await _manualsService.CreateAsync(manual); return(Ok(manual.Id)); }
public ActionResult Save(ManualViewModel model) { try { string pathFile = @"~/App_Data/Manual.txt"; var fileContents = System.IO.File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(pathFile)); System.IO.File.WriteAllText(System.Web.HttpContext.Current.Server.MapPath(pathFile), model.ManualText); DisplaySuccessMessage("Successfully updated manual text!"); return(RedirectToAction("Index", "Admin")); } catch (Exception e) { DisplayErrorMessage("Error ocurred, failed updating manual text!"); return(RedirectToAction("Index")); } }
public ActionResult Index() { try { string pathFile = @"~/App_Data/Manual.txt"; var fileContents = System.IO.File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(pathFile)); ManualViewModel mvm = new ManualViewModel(); mvm.ManualText = fileContents; return(View(mvm)); } catch (Exception e) { DisplayErrorMessage("Error ocurred, failed loading current manual text, enter new and save!"); return(View()); } }
public async Task <IActionResult> Manual(int id) { var user = await _userManager.GetUserAsync(User); Manual manual = context.Manuals.Find(id); ManualViewModel model = new ManualViewModel { Manual = manual, Steps = context.Steps.Where(s => s.ManualId == manual.ManualId).ToList(), Comments = context.Comments.Where(c => c.ManualId == manual.ManualId).ToList(), User = user, Context = context, Tags = ManualHelper.GetAllManualTags(id, context) }; return(View(model)); }
public ActionResult CreateNewManual(ManualViewModel model, string ReturnUrl = "/") { if (ModelState.IsValid) { var currentUserId = User.Identity.GetUserId(); model.UserId = currentUserId; model.DateAdded = DateTime.Now; if (model.TemplateId == 3) { model.VideoLink = model.VideoLink.Substring(model.VideoLink.IndexOf("v=") + 2, 11); } Manual manual = Mapper.Map <Manual>(model); manualRepository.Add(manual); manualRepository.Save(); MedalsCheck(); return(Json(new { result = "Redirect", url = ReturnUrl })); } return(View(model)); }
// GET: Manuals/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Manual manual = db.Manuals.SingleOrDefault(x => x.Id == id); if (manual == null) { return(HttpNotFound()); } ManualViewModel vm = new ManualViewModel { Id = manual.Id, Name = manual.Name, }; return(View(vm)); }