public async Task <IActionResult> ServicerDetail(ServicerModel model) { var applicationUser = await _userManager.GetUserAsync(new System.Security.Claims.ClaimsPrincipal(User.Identity)); if (applicationUser == null || string.IsNullOrEmpty(applicationUser.OrganizationId)) { return(new JsonResult(new { Code = "400", Message = "用户登录异常,请先登录。" })); } model.Category = string.IsNullOrEmpty(model.Category) ? "" : model.Category; model.SubCategory = (string.IsNullOrEmpty(model.SubCategory) || model.SubCategory == "请选择") ? null : model.SubCategory; model.PersonalIntroduction = string.IsNullOrEmpty(model.PersonalIntroduction) ? "" : model.PersonalIntroduction; var url = "http://fancyservice.gooios.com/api/servicer/v1"; if (string.IsNullOrEmpty(model.Id)) { model.OrganizationId = applicationUser.OrganizationId; var jsonObj = JsonConvert.SerializeObject(model); await HttpRequestHelper.PostNoResultAsync(url, jsonObj, "768960bff18111e79916016898e9f885", applicationUser.Id); } else { model.OrganizationId = applicationUser.OrganizationId; var jsonObj = JsonConvert.SerializeObject(model); await HttpRequestHelper.PutNoResultAsync(url, jsonObj, "768960bff18111e79916016898e9f885", applicationUser.Id); } return(new JsonResult(new { Code = "200", Message = "保存成功。" })); }
public async Task <IActionResult> ServicerDetail(string id = null) { ViewBag.Operation = string.IsNullOrEmpty(id?.Trim()) ? "add" : "update"; var applicationUser = await _userManager.GetUserAsync(new System.Security.Claims.ClaimsPrincipal(User.Identity)); if (applicationUser == null || string.IsNullOrEmpty(applicationUser.OrganizationId)) { return(RedirectToAction("Login", "Account")); } var categories = await HttpRequestHelper.GetAsync <List <CategoryModel> >("http://fancyservice.gooios.com/api/category/v1/getbymark", "mark=Servicer", "768960bff18111e79916016898e9f885", applicationUser.Id); var serviceCategories = categories.Where(o => string.IsNullOrEmpty(o.ParentId)).Select(item => { return(new CategoryModel { Id = item.Id, Name = item.Name, ParentId = item.ParentId, Children = categories.Where(g => g.ParentId == item.Id).ToList() }); }).ToList(); ViewBag.Categories = serviceCategories; ViewBag.CategoriesJson = JsonConvert.SerializeObject(serviceCategories); ServicerModel model = string.IsNullOrEmpty(id) ? null : await HttpRequestHelper.GetAsync <ServicerModel>($"http://fancyservice.gooios.com/api/servicer/v1/getbyid", $"id={id}", "768960bff18111e79916016898e9f885", applicationUser.Id); return(View(model)); }
public Task <IActionResult> Edit(ServicerModel model) { return(this.JsonResultAsync(() => { model.OperateUserID = AdminID; return _servicerApplication.EditServicerAsync(model); })); }
/// <summary> /// 修改服务器信息 /// </summary> /// <param name="servicerModel">服务器信息</param> /// <returns>操作结果</returns> public Task <OperateResult> EditServicerAsync(ServicerModel servicerModel) { return(OperateUtil.ExecuteAsync(async() => { var servicerInfo = _servcerDomainService.Create(servicerModel); var flag = await LockUtil.ExecuteWithLockAsync(Lock_ServicerModify, servicerInfo.FMacAddress, TimeSpan.FromMinutes(2), async() => { await _servcerDomainService.CheckAsync(servicerInfo); await _servcerRepository.UpdateAsync(servicerInfo, m => m.FID == servicerInfo.FID, ignoreFields: IDAndCreate); _operateLogDomainService.AddOperateLog(servicerModel.OperateUserID, OperateModule.Servicer, OperateModuleNode.Edit, $"修改:{servicerInfo.GetOperateDesc()}"); _servcerDomainService.ServicerChanged(OperateType.Modify, servicerInfo.FID); return true; }, defaultValue: false); if (!flag) { throw new BizException("修改失败"); } }, callMemberName: "ServicerApplication-AddServicerAsync")); }
/// <summary> /// 添加服务器信息 /// </summary> /// <param name="servicerModel">服务器信息</param> /// <returns>操作结果</returns> public Task <OperateResult> AddServicerAsync(ServicerModel servicerModel) { return(OperateUtil.ExecuteAsync(async() => { var servicerInfo = _servcerDomainService.Create(servicerModel); int id = await LockUtil.ExecuteWithLockAsync(Lock_ServicerModify, servicerInfo.FMacAddress, TimeSpan.FromMinutes(2), async() => { await _servcerDomainService.CheckAsync(servicerInfo); int servicerID = (await _servcerRepository.InsertOneAsync(servicerInfo, keyName: "FID", ignoreFields: FID)).ToSafeInt32(0); _operateLogDomainService.AddOperateLog(servicerModel.OperateUserID, OperateModule.Servicer, OperateModuleNode.Add, $"添加:{servicerInfo.GetOperateDesc()}"); _servcerDomainService.ServicerChanged(OperateType.Add, servicerID); return servicerID; }, defaultValue: -1); if (id <= 0) { throw new BizException("添加失败"); } }, callMemberName: "ServicerApplication-AddServicerAsync")); }
/// <summary> /// 根据Model创建服务器信息 /// </summary> /// <param name="servicerModel">Model信息</param> /// <returns>服务器信息</returns> public ServicerInfo Create(ServicerModel servicerModel) { servicerModel.NotNull("服务器信息不能为空"); var servicerInfo = new ServicerInfo { FComment = servicerModel.FComment, FIP = servicerModel.FIP, FIsDeleted = false, FName = servicerModel.FName, FID = servicerModel.FID, FMacAddress = servicerModel.FMacAddress, FCreateTime = DateTimeUtil.Now, FCreateUserID = servicerModel.OperateUserID }; if (servicerModel.FID > 0) { servicerInfo.FLastModifyTime = DateTimeUtil.Now; servicerInfo.FLastModifyUserID = servicerModel.OperateUserID; } return(servicerInfo); }