public VRequestInfo SaveNavigationImgPlays(ImgPlayDto input) { if (input.NavigationID != -1) { var navModel = navigationRepositrory.Query(input.NavigationID); if (navModel == null || navModel.Id == 0) { return(VRequestInfo.ErrorResult("导航不存在")); } } bool res = false; if (input.Id == 0) { input.IsDisable = Models.Enum.EYesOrNo.No; input.CreateTime = DateTime.Now; res = playInfoRepository.Insert(ModelConvertUtil <ImgPlayDto, ImgPlayInfo> .ModelCopy(input)) > 0; } else { var model = ModelConvertUtil <ImgPlayDto, ImgPlayInfo> .ModelCopy(input); res = playInfoRepository.Update(model); } if (res) { return(VRequestInfo.SuccessResult()); } else { return(VRequestInfo.ErrorResult("保存失败")); } }
public virtual async Task <IActionResult> Upload([FromServices] IHostingEnvironment env) { UploadFileModel upload = new UploadFileModel(); var files = Request.Form.Files; if (files.Count > 0) { var file = files[0]; string md5code = string.Empty; using (var inputStream = file.OpenReadStream()) { using (var md5 = System.Security.Cryptography.MD5.Create()) { byte[] retVal = md5.ComputeHash(inputStream); StringBuilder md5sb = new StringBuilder(); for (int i = 0; i < retVal.Length; i++) { md5sb.Append(retVal[i].ToString("x2")); } md5code = md5sb.ToString(); } } // 文件名完整路径 upload.extension = Path.GetExtension(file.FileName); upload.fileName = md5code + upload.extension; var path = string.Format(@"\images\Upload\{0}\{1}", DateTime.Today.Year.ToString(), DateTime.Today.Month.ToString().PadLeft(2, '0')); upload.path = string.Format(@"{0}\{1}", path, upload.fileName); upload.fullPath = UrlCommon.CreateUrlPath(Request.GetSiteUri(), upload.path); var savedFilePath = env.WebRootPath + path; if (!Directory.Exists(savedFilePath)) { Directory.CreateDirectory(savedFilePath); } var fullFileNamePath = Path.Combine(savedFilePath, upload.fileName); if (!System.IO.File.Exists(fullFileNamePath)) { try { using (var fileStream = new FileStream(fullFileNamePath, FileMode.Create)) { await file.CopyToAsync(fileStream); } } catch (Exception ex) { } } return(new JsonResult(VRequestInfo.SuccessResult("上传成功", upload))); } return(new JsonResult(VRequestInfo.ErrorResult("上传失败"))); }
public async Task <IActionResult> Login(VLoginInfo input, string returnUrl = "") { ViewData["Title"] = this.Config.SystemName; VRequestInfo msg = new VRequestInfo(); if (!ModelState.IsValid) { msg.Code = VRequestInfo.Error; msg.Msg = GetModelError(ModelState); msg.Data = RandomHelper.GetRandomCode(); return(View(msg)); } var user = accountService.Login(input.UserName, input.Password); if (user != null && user.Id > 0) { var identity = new ClaimsIdentity(SystemConfig.UserCookie); identity.AddClaim(new Claim(ClaimTypes.Sid, user.Id.ToString())); identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName)); identity.AddClaim(new Claim(ClaimTypes.Surname, user.RealName)); identity.AddClaim(new Claim(ClaimTypes.Role, UserType.Administrator)); // 暂且都为管理人员 identity.AddClaim(new Claim(ClaimTypes.MobilePhone, user.Mobile)); identity.AddClaim(new Claim(ClaimTypes.Email, user.Email)); await HttpContext.SignInAsync(SystemConfig.UserCookie, new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = true, ExpiresUtc = DateTimeOffset.Now.Add(TimeSpan.FromMinutes(30)) }); if (string.IsNullOrEmpty(returnUrl)) { returnUrl = TempData["returnUrl"]?.ToString(); } if (!string.IsNullOrEmpty(returnUrl) && returnUrl != "/") { return(Redirect(returnUrl)); } else { return(RedirectToAction(nameof(HomeController.Index), "Home")); } } else { msg.Code = VRequestInfo.Error; msg.Msg = "用户名或密码不正确"; msg.Data = RandomHelper.GetRandomCode(); return(View(msg)); } }
public VRequestInfo GetNavigationDetail(int id) { VRequestInfo res = new VRequestInfo(); var info = navigationRepositrory.Query(id); if (info == null) { return(VRequestInfo.ErrorResult("导航不存在")); } res.Data = ModelConvertUtil <NavigationInfo, NavigationDto> .ModelCopy(info); res.Code = VRequestInfo.Success; return(res); }
public VRequestInfo SwitchNavigationImgPlays(VSlideshowSwitchInput input) { var list = playInfoRepository.GetModelByIdList(input.Ids.ToArray()); if (list.Count == input.Ids.Count) { list.ForEach(i => { i.IsDisable = input.Off; playInfoRepository.Update(i); }); return(VRequestInfo.SuccessResult("更新完成")); } return(VRequestInfo.ErrorResult("无效操作")); }
public VRequestInfo DeleteNavigationImgPlays(VSlideshowSwitchInput input) { var list = playInfoRepository.GetModelByIdList(input.Ids.ToArray()); if (list.Count == input.Ids.Count) { var res = playInfoRepository.DeleteImgPlaysAsync(input.Ids); if (res.Result) { return(VRequestInfo.SuccessResult("删除完成")); } else { return(VRequestInfo.ErrorResult("删除失败")); } } return(VRequestInfo.ErrorResult("无效操作")); }
public VRequestInfo EditNavigation(VNavigationEdit input) { int res = 0; if (input.navigationId == 0 && input.parentNavigationId == 0) { //新增一级导航 var navInfo = new NavigationInfo() { }; navigationRepositrory.Insert(navInfo); } else if (input.navigationId == 0) { //新增子导航 } else { //修改导航名称 } return(res > 0 ? VRequestInfo.SuccessResult("操作成功") : VRequestInfo.ErrorResult("操作失败")); }
public IActionResult Show(VRequestInfo info) { return(new JsonResult(info)); }
public IActionResult ShowSuccess(string msg, object data = null) { return(new JsonResult(VRequestInfo.SuccessResult(msg, data))); }
public IActionResult ShowError(string msg) { return(new JsonResult(VRequestInfo.ErrorResult(msg))); }
public IActionResult Login(string returnUrl = "") { ViewData["Title"] = this.Config.SystemName; TempData["returnUrl"] = returnUrl; return(View(VRequestInfo.DefaultResult("", RandomHelper.GetRandomCode()))); }