public void Show(TypeViewModel type, bool adjustExpansion) { _types = null; Type = type; Graph = CreateGraph(type, adjustExpansion); OnGraphChanged(); }
public IActionResult SaveEntity(TypeViewModel productVm) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); ErrorMesage e = new ErrorMesage(); if (productVm.SortOrder == 0) { e.Message = "Vui lòng nhập SortOrder"; e.Error = true; return(new BadRequestObjectResult(e)); } return(new BadRequestObjectResult(allErrors)); } else { productVm.SeoAlias = TextHelper.ToUnsignString(productVm.Name); if (productVm.Id == 0) { _typeService.Add(productVm); } else { _typeService.Update(productVm); } _typeService.Save(); return(new OkObjectResult(productVm)); } }
public ActionResult Edit(TypeViewModel typeVM) { try { if (ModelState.IsValid) { using (TypeServiceReference.TypeClient service = new TypeServiceReference.TypeClient()) { TypeDto typeDto = new TypeDto { Id = typeVM.Id, Name = typeVM.Name, Description = typeVM.Description }; service.PostType(typeDto); } return(RedirectToAction("Index")); } return(View()); } catch { return(View()); } }
/// <summary> /// Update tax value /// </summary> /// <param name="obj">New Tax value</param> /// <returns></returns> public ApiResponseViewModel Update(Model.Models.Type obj) { var result = new TypeViewModel(); var response = new ApiResponseViewModel { Code = CommonConstants.ApiResponseSuccessCode, Message = null, Result = null }; try { var exists = _TypeRepository.CheckContains(m => m.ID == obj.ID); if (exists) { _TypeRepository.Update(obj); _unitOfWork.Commit(); response.Message = CommonConstants.SaveSuccess; } else { response.Code = CommonConstants.ApiResponseNotFoundCode; response.Message = CommonConstants.NotFoundMessage; } } catch (Exception ex) { response.Code = CommonConstants.ApiResponseExceptionCode; response.Message = CommonConstants.ErrorMessage + " " + ex.Message; } return(response); }
//編輯頁面 > 取得表單簽核資料類型 public TypeViewModel GetTypeData(int formID) { TypeViewModel model = null; string strSQL = @"Select * from SignType where FormID = @FormID"; var strCondition = new Conditions() { { "@FormID", formID } }; var result = _dc.QueryForDataRow(strSQL, strCondition); if (result == null) { return(null); } model = new TypeViewModel() { FormID = Int32.Parse(result["FormID"].ToString()), FormType = result["FormType"].ToString(), SignID_FK = result["SignID_FK"].ToString(), FilingDepartmentID_FK = result["FilingDepartmentID_FK"].ToString(), Modifier = result["Modifier"].ToString(), ModifyDate = !result["ModifyDate"].IsDBNullOrWhiteSpace() ? DateTime.Parse(result["ModifyDate"].ToString()) : DateTime.Parse(result["CreateDate"].ToString()), TimeStamp = (result["ModifyDate"].IsDBNullOrWhiteSpace() ? result["CreateDate"].ToString() : result["ModifyDate"].ToString()).ToDateFormateString(), DepartmentDic = _rootRepo.GetDepartment(), SignIDDic = _rootRepo.GetSignProcedure(), }; return(model); }
/// <summary> /// Get Tax value by id /// </summary> /// <param name="id">ID of Tax value</param> /// <returns></returns> public ApiResponseViewModel GetById(int id) { var result = new TypeViewModel(); var response = new ApiResponseViewModel { Code = CommonConstants.ApiResponseSuccessCode, Message = null, Result = null }; try { var exists = _TypeRepository.CheckContains(m => m.ID == id); if (exists) { var tempResult = _TypeRepository.GetSingleById(id); result.ID = tempResult.ID; result.TypeName = tempResult.TypeName; result.IsActive = tempResult.IsActive ?? false; response.Result = result; } else { response.Code = CommonConstants.ApiResponseNotFoundCode; response.Message = CommonConstants.NotFoundMessage; } } catch (Exception ex) { response.Code = CommonConstants.ApiResponseExceptionCode; response.Message = CommonConstants.ErrorMessage + " " + ex.Message; } return(response); }
private static TypeGraph CreateGraph(TypeViewModel typeViewModel, bool adjustExpansion) { var graph = new TypeGraph(true); if (adjustExpansion) { ExpandAll(typeViewModel); if (typeViewModel.DescendantsCount > 100) { AdjustExpansion(typeViewModel); } } else { typeViewModel.IsExpanded = true; if (typeViewModel.DescendantsCount <= 100) { ExpandAll(typeViewModel); } } var flattenedHierarchy = typeViewModel.FlattenedHierarchy; graph.AddVertexRange(flattenedHierarchy); foreach (var viewModel in flattenedHierarchy) { if (viewModel.BaseType == null || viewModel == typeViewModel) { continue; } graph.AddEdge(new Edge <TypeViewModel>(viewModel, viewModel.BaseType)); } return(graph); }
object UnwrapInputVariableFromViewModel() { if (_inputVariable == null) { return(null); } AssemblyViewModel assemblyVM = _inputVariable as AssemblyViewModel; if (assemblyVM != null) { return(assemblyVM.GetAssemblyInternal()); } TypeViewModel typeVM = _inputVariable as TypeViewModel; if (typeVM != null) { return(typeVM.GetTypeInternal()); } ObjectViewModel objectVM = _inputVariable as ObjectViewModel; if (objectVM != null) { return(objectVM.GetInstanceInternal()); } Debug.Fail("Unexpected input variable type: " + _inputVariable.GetType()); return(null); }
// GET: Type public ActionResult ViewTypes() { TypeViewModel TypeModel = new TypeViewModel(); TypeModel.TypeList = mapper.TypeMap(TypeData.GetAllTypes()); return(View(TypeModel)); }
public ActionResult Edit(string id, FormCollection fc) { PublicationViewModel p = Pubtracker2FrontEnd.ptHelper.EditPubVM(id); p.vmPublication.PublicationId = fc["vmPublication.PublicationId"].ToString(); p.vmPublication.SortId = Convert.ToInt32(fc["vmPublication.SortId"].ToString()); p.vmPublication.Title = fc["vmPublication.Title"]; string typeValue = fc["Type"]; p.vmPublication.Series = fc["vmPublication.Series"].ToString(); string divisionValue = fc["Division"]; p.vmPublication.Remarks = fc["vmPublication.Remarks"].ToString(); string typeText = p.slType.ToList().Find(x => x.Value == typeValue).Text; string divisionText = p.slDivision.ToList().Find(x => x.Value == divisionValue).Text; TypeViewModel type = new TypeViewModel(); type.TypeId = typeValue; type.TypeName = typeText; p.vmPublication.Type = type; DivisionViewModel division = new DivisionViewModel(); division.DivisionId = divisionValue; division.DivisionName = divisionText; p.vmPublication.Division = division; if (Pubtracker2FrontEnd.ptHelper.Edit <ptPublication>(id, "publications", p.vmPublication)) { return(RedirectToAction("Index")); } else { return(View(p)); } }
public IEnumerable <TypeViewModel> GetAllTypeViewModels() { var types = new List <TypeViewModel>(); foreach (var type in _repository.GetAllTypes()) { var typeCars = new List <CarViewModel>(); foreach (var car in GetAllCarViewModels()) { if (car.TypeLabel.Equals(type.Brand + " " + type.Model)) { typeCars.Add(car); } } var typeView = new TypeViewModel() { Id = type.Id, Brand = type.Brand, Model = type.Model, Cars = typeCars }; types.Add(typeView); } return(types); }
public IActionResult PutRecipeType(TypeViewModel viewModel) { var type = mapper.Map <RecipeType>(viewModel); recipeTypeRepository.Update(type); return(RedirectToAction(nameof(GetRecipeType), new { id = type.Id })); }
public IActionResult PostRecipeType(TypeViewModel viewModel) { var type = mapper.Map <RecipeType>(viewModel); recipeTypeRepository.Create(type); return(RedirectToAction(nameof(GetRecipeTypes))); }
// GET: Eier/Delete/5 public async Task <IActionResult> DeleteBok(int?id) { if (id == null) { return(NotFound()); } KlistremerkeBok bok = await _context.Boker .SingleOrDefaultAsync(m => m.Id == id); if (bok == null) { return(NotFound()); } TypeViewModel model = new TypeViewModel { StatusMessage = StatusMessage, Navn = bok.Navn, Id = bok.Id }; return(View(model)); }
// GET: Eier/Delete/5 public async Task <IActionResult> DeleteType(int?id) { if (id == null) { return(NotFound()); } BokType type = await _context.BokTyper .SingleOrDefaultAsync(m => m.Id == id); if (type == null) { return(NotFound()); } TypeViewModel model = new TypeViewModel { StatusMessage = StatusMessage, Navn = type.Type, Id = type.Id }; return(View(model)); }
public ActionResult Create() { var model = new TypeViewModel(); model.TypeIsActiveList = new List <SelectListItem>(); model.TypeIsActiveList.Add(new SelectListItem() { Text = "Active", Value = "true" }); model.TypeIsActiveList.Add(new SelectListItem() { Text = "Inactive", Value = "false" }); model.Status = true; using (var facade = new TypeFacade()) { model.TypeCode = facade.GetNextTypeCode().ToString(); } ViewBag.CreateUsername = UserInfo.FullName; ViewBag.UpdateUsername = UserInfo.FullName; ViewBag.CreateDate = DateTime.Now; ViewBag.UpdateDate = DateTime.Now; return(View(model)); }
public TypeViewModel Add(TypeViewModel typeViewModel) { var productCategory = typeViewModel.AddModel(); _typeRepository.Add(productCategory); return(typeViewModel); }
public BerryContext() { if (VM_Berry == null) { VM_Berry = new BerryViewModel(); } if (VM_Item == null) { VM_Item = new ItemViewModel(); } if (VM_Type == null) { VM_Type = new TypeViewModel(); } if (VM_Category == null) { VM_Category = new CategoryViewModel(); } if (VM_Pocket == null) { VM_Pocket = new PocketViewModel(); } if (VM_Generation == null) { VM_Generation = new GenerationViewModel(); } if (VM_Region == null) { VM_Region = new RegionViewModel(); } if (VM_DamageClass == null) { VM_DamageClass = new DamageClassViewModel(); } if (VM_Language == null) { VM_Language = new LanguageViewModel(); } if (VM_ContestType == null) { VM_ContestType = new ContestTypeViewModel(); } }
/// <summary> /// Type used in knockout for the observable. /// </summary> public static string ObservableConstructorCall(this TypeViewModel typeModel) { if (typeModel.IsByteArray) { return("ko.observable(null)"); } if (typeModel.IsCollection || typeModel.IsArray) { return("ko.observableArray([])"); } else if (typeModel.IsDate) { if (typeModel.IsNullable) { return("ko.observable(null)"); } else { return("ko.observable(moment())"); } } else { return("ko.observable(null)"); } }
/// <summary> /// 获取一个单词包 /// </summary> /// <returns></returns> public List <WordModel> GetAWordList() { List <string> wordPackList = new List <string>(); foreach (var file in Directory.GetFiles(WordPackPath)) { string filename = Path.GetFileName(file); if (filename.StartsWith(WordPackIdentifier)) { wordPackList.Add(file); } } List <WordModel> wordList; if (wordPackList.Count > 0) { string currentFile = wordPackList[new Random().Next(0, wordPackList.Count)]; wordList = new List <WordModel>(TypeViewModel.ReadFromFile(currentFile)); } else { wordList = new List <WordModel>() { new WordModel() { Source = "YZTXDY", Meaning = "The first Motto" } }; } return(wordList); }
public async Task <ActionResult> Create(TypeViewModel typeVM) { try { string accessToken = await GetAccessToken(); using (var client = new HttpClient()) { client.BaseAddress = url; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Add the Authorization header with the AccessToken. client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken); var content = JsonConvert.SerializeObject(typeVM); var buffer = System.Text.Encoding.UTF8.GetBytes(content); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // make the request HttpResponseMessage response = await client.PostAsync("post", byteContent); // parse the response and return the data. //string jsonString = await response.Content.ReadAsStringAsync(); //var responseData = JsonConvert.DeserializeObject<GenreVM>(jsonString); //return View(responseData); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult SearchTypeList(TypeSearchFilter searchFilter) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Type").ToInputLogString()); try { if (ModelState.IsValid) { _typeFacade = new TypeFacade(); TypeViewModel typeVm = new TypeViewModel(); typeVm.SearchFilter = searchFilter; typeVm.TypeList = _typeFacade.GetTypeList(typeVm.SearchFilter); ViewBag.PageSize = typeVm.SearchFilter.PageSize; return(PartialView("~/Views/Type/_TypeList.cshtml", typeVm)); } return(Json(new { Valid = false, Error = string.Empty })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Type").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult Index() { Logger.Info(_logMsg.Clear().SetPrefixMsg("List Type").ToInputLogString()); try { var typeVM = new TypeViewModel(); typeVM.SearchFilter = new TypeSearchFilter { TypeName = string.Empty, Status = string.Empty, PageNo = 1, PageSize = 15, SortField = "AreaName", SortOrder = "ASC" }; ViewBag.PageSize = typeVM.SearchFilter.PageSize; ViewBag.Message = string.Empty; return(View(typeVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Type").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
private static void ExpandAll(TypeViewModel typeViewModel) { typeViewModel.IsExpanded = true; foreach (var type in typeViewModel.DerivedTypes) { ExpandAll(type); } }
public void DeleteType(TypeViewModel type) { Type selectedType = _typeRepository.GetById <int>(type.Id); selectedType.Status = (int)DbConstant.DefaultDataStatus.Deleted; _typeRepository.Update(selectedType); _unitOfWork.SaveChanges(); }
public void UpdateType(TypeViewModel type) { Type entity = _typeRepository.GetById <int>(type.Id); Map(type, entity); _typeRepository.Update(entity); _unitOfWork.SaveChanges(); }
public async Task <IActionResult> GetPokemonTypeInfo(string name) { var typeViewModel = new TypeViewModel(); typeViewModel = await _pokemonService.GetTypeInformation(name); return(View(typeViewModel)); }
public string ConfirmEditType(TypeViewModel vm) { TypeDomainModel t_dm = new TypeDomainModel(); var mapper_accs = new MapperConfiguration(cfg => cfg.CreateMap <TypeViewModel, TypeDomainModel>()).CreateMapper(); var trans = mapper_accs.Map <TypeViewModel, TypeDomainModel>(vm); string response = t.EditType(trans); return(response); }
/// <summary> /// Write metadata common to all type representations, /// like properties, method parameters, method returns, etc. /// </summary> private void WriteTypeCommonMetadata(TypeScriptCodeBuilder b, TypeViewModel type) { void WriteTypeDiscriminator(string propName, TypeViewModel t) { var kind = t.TsTypeKind; switch (kind) { case TypeDiscriminator.Unknown: // We assume any unknown props are strings. b.Line("// Type not supported natively by Coalesce - falling back to string."); b.StringProp(propName, "string"); break; default: b.StringProp(propName, kind.ToString().ToLowerInvariant()); break; } } void WriteTypeDef(string propName, TypeViewModel t) { var kind = t.TsTypeKind; switch (kind) { case TypeDiscriminator.Enum: b.Line($"get {propName}() {{ return domain.enums.{t.Name} }},"); break; case TypeDiscriminator.Model: case TypeDiscriminator.Object: b.Line($"get {propName}() {{ return {GetClassMetadataRef(t.ClassViewModel)} }},"); break; } } WriteTypeDiscriminator("type", type); WriteTypeDef("typeDef", type); // For collections, write the references to the underlying type. if (type.TsTypeKind == TypeDiscriminator.Collection) { if (type.PureType.TsTypeKind == TypeDiscriminator.Collection) { throw new InvalidOperationException("Collections of collections aren't supported by Coalesce as exposed types"); } using (b.Block($"itemType:", ',')) { b.StringProp("name", "$collectionItem"); b.StringProp("displayName", ""); b.StringProp("role", "value"); WriteTypeCommonMetadata(b, type.PureType); } } }
public static TypeViewModel GetTypeVM() { if (typeVM == null) { typeVM = new TypeViewModel(); } return(typeVM); }
public ActionResult AddType(TypeViewModel model) { if (!ModelState.IsValid) { return View(); } else { Types.AddType(model); return RedirectToAction("AllEventTypes", "Events"); } }
public void AddDerivedType(TypeViewModel typeViewModel) { _derivedTypes.Add(typeViewModel); typeViewModel.BaseType = this; }
List<TypeViewModel> LoadTypesInAssembly() { List<TypeViewModel> list = new List<TypeViewModel>(); foreach (Type type in _assembly.GetTypes()) { TypeViewModel typeVM = new TypeViewModel(type, this); // Exclude the Private Implementation Details classes. if (!type.FullName.Contains("<") && !type.FullName.Contains("$")) { typeVM.PropertyChanged += this.OnTypeViewModelPropertyChanged; list.Add(typeVM); } } list.Sort((t1, t2) => { bool t1IsInternal = t1.UnqualifiedName.StartsWith("_"); bool t2IsInternal = t2.UnqualifiedName.StartsWith("_"); if (t1IsInternal && !t2IsInternal) return +1; if (!t1IsInternal && t2IsInternal) return -1; return (t1.UnqualifiedName.CompareTo(t2.UnqualifiedName)); }); return list; }
private TypeViewModel GetViewModelForType(TypeInfo typeInfo) { if (_viewModelCorrespondence.ContainsKey(typeInfo)) { return _viewModelCorrespondence[typeInfo]; } var viewModel = new TypeViewModel(typeInfo, this); _viewModelCorrespondence.Add(typeInfo, viewModel); return viewModel; }
private bool IsWpfInternalType(TypeViewModel type) { return WpfInternalTypes.Contains(type.Name) && WpfAssemblies.Contains(type.TypeInfo.Module.Assembly.Name); }