public async Task <IActionResult> GetInventoryObjectTypesListPartial(int id) { string apiUrl = $"api/inventory/types/byInventoryObjectId/{id}"; var httpClient = await _facilityManagementHttpClient.GetClient(); var response = await httpClient.GetAsync(apiUrl).ConfigureAwait(false); if (response.IsSuccessStatusCode) { var responseAsString = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var compressorTypesViewModel = new TypesViewModel { InventoryObjectId = id, Types = JsonConvert.DeserializeObject <ICollection <InventoryObjectTypeDTO> >(responseAsString) }; return(PartialView("_TypesPartial", compressorTypesViewModel)); } else if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized || response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { return(RedirectToAction("AccessDenied", "Authorization")); } throw new Exception($"A problem happened while calling the API: {response.ReasonPhrase}"); }
public void GetViewTest() { var model = _applicationDbContext.Types.First(); TypesViewModel updateModel = _typesService.GetView(model.ID); Assert.IsNotNull(updateModel); }
public IActionResult Get() { TypesViewModel types = new TypesViewModel(); List <string> workTypes = new List <string>(); foreach (WorkType val in Enum.GetValues(typeof(WorkType))) { workTypes.Add(val.ToString()); } types.WorkTypes = workTypes; return(new OkObjectResult(types)); }
public async Task <IActionResult> Index(int page = 1) { TypesViewModel typesView = new TypesViewModel { Types = new List <ItemType>() }; var user = await Authorize(); if (user != null && user.Roles.Any(r => r.Name == "Пользователь")) { var types = _repositoryType.GetAll(); var list = await types.OrderByDescending(t => t.Id).Skip((page - 1) * 10).Take(10).ToListAsync(); typesView.Types = list; typesView.Page = new PagingViewModel(page, await types.CountAsync(), 10); } return(View(typesView)); }
public ActionResult Add(TypesViewModel t) { try { if (ModelState.IsValid) { db.Operations.Add(new Operations { NameOp = t.Name, TypeId = t.TypeId, TypeOperations = db.TypeOperations.Single(x => x.TypeId == t.TypeId) }); db.SaveChanges(); } return(new HttpStatusCodeResult(201)); //need to be changed } catch { return(new HttpStatusCodeResult(501)); //need to be changed } }
public ActionResult Edit(TypesViewModel t) { Operations op = new Operations { NameOp = t.Name, OpId = t.Id, TypeId = t.TypeId }; try { if (ModelState.IsValid) { db.Entry(op).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(new HttpStatusCodeResult(201)); //need to be changed } catch { return(new HttpStatusCodeResult(501)); //need to be changed } }
public TypesOverviewPage() { InitializeComponent(); BindingContext = viewModel = new TypesViewModel(); }