public void ModelState_IsValid_ForValidData_OnDerivedModel() { // Arrange var testContext = ModelBindingTestHelper.GetTestContext(); var modelState = testContext.ModelState; var model = new SoftwareViewModel { Category = "Technology", CompanyName = "Microsoft", Contact = "4258393231", Country = "USA", DatePurchased = new DateTime(2010, 10, 10), Name = "MVC", Price = 110, Version = "2" }; var controller = CreateController(testContext, testContext.MetadataProvider); // Act var result = controller.TryValidateModel(model); // Assert Assert.True(result); Assert.True(modelState.IsValid); var modelStateErrors = GetModelStateErrors(modelState); Assert.Empty(modelStateErrors); }
public void ModelState_IsInvalid_ForInvalidData_OnDerivedModel() { // Arrange var testContext = ModelBindingTestHelper.GetTestContext(); var modelState = testContext.ModelState; var model = new SoftwareViewModel { Category = "Technology", CompanyName = "Microsoft", Contact = "4258393231", Country = "UK", // Here the validate country is USA only DatePurchased = new DateTime(2010, 10, 10), Price = 110, Version = "2" }; var controller = CreateController(testContext, testContext.MetadataProvider); // Act var result = controller.TryValidateModel(model, prefix: "software"); // Assert Assert.False(result); Assert.False(modelState.IsValid); var modelStateErrors = GetModelStateErrors(modelState); Assert.Single(modelStateErrors); Assert.Equal("Product must be made in the USA if it is not named.", modelStateErrors["software"]); }
public ActionResult GetOverViewNewsForSoftware(SoftwareViewModel softwaremodel) { try { int SoftwareCategoryID = 0; if (Session["SoftwareCategory"] != null) { SoftwareCategoryID = new FocusAreaService().GetSoftwareCategoryID(Session["SoftwareCategory"].ToString()); } OverviewNewsEntity NewsFilter = new OverviewNewsEntity { CategoryID = SoftwareCategoryID, IsCompanySoftware = 2, location = "", SubcategoryID = "", CompanySoftwareID = 0 }; OverviewAndNewsService newsService = new OverviewAndNewsService(); OverviewNewsViewModel newsViewModel = newsService.GetCompanySoftwareNews(NewsFilter); return(PartialView("~/Views/SoftwareList/_SoftwareNewsList.cshtml", newsViewModel)); } catch (Exception ex) { return(null); } }
public ActionResult PartialDetails(int id) { var software = _softwareService.GetSoftware(id); if (software == null) { return(NotFound()); } var model = new SoftwareViewModel() { Id = software.Id, Name = software.Name, ShortDescription = string.IsNullOrEmpty(software.Description) ? "" : CreateShortDescription(software.Description), Publisher = software.Publisher.Name, Developer = software.Developer.Name, RecomendedCPURequirmentsDisplay = CreateCPuDisplay(software.SoftwareCPURequirements.Where(m => m.RequirementTypeId == 2).ToList()), RecomendedVideoCardRequirmentsDisplay = CreateVideoCardDisplay(software.SoftwareVideoCardRequirements.Where(m => m.RequirementTypeId == 2).ToList()), MinimiumRequiredRAMDisplay = software.MinimiumRequiredRAM + " Гб", RecommendedRequiredRAMDisplay = software.RecommendedRequiredRAM + " Гб", DiscVolumeDisplay = CreateMemoryDescription(software.DiscVolume), MinimumCPURequirmentsDisplay = CreateCPuDisplay(software.SoftwareCPURequirements.Where(m => m.RequirementTypeId == 1).ToList()), MinimumVideoCardRequirmentsDisplay = CreateVideoCardDisplay(software.SoftwareVideoCardRequirements.Where(m => m.RequirementTypeId == 1).ToList()), ImagePath = "/Images/Software/" + software.Image, Price = software.Price, Description = software.Description }; return(PartialView(model)); }
public static SoftwareViewModel ConvertToViewModel(Software s) { var software = new SoftwareViewModel { isSubscription = s.isSubscription, isDownload = s.isDownload, isDownSub = s.isDownSub, ProductName = s.ProductName, ProductCategory = s.ProductCategory, ShortDescription = s.ShortDescription, LongDescription = s.LongDescription, Price = s.Price, VideoUrl = s.VideoUrl, PictureUrl1 = s.PictureUrl1, PictureUrl2 = s.PictureUrl2, PictureUrl3 = s.PictureUrl3, PictureUrl4 = s.PictureUrl4, PictureUrl5 = s.PictureUrl5, PictureUrl6 = s.PictureUrl6, PictureUrl7 = s.PictureUrl7, PictureUrl8 = s.PictureUrl8, }; return(software); }
public void ModelState_IsValid_ForValidData_OnDerivedModel() { // Arrange var testContext = ModelBindingTestHelper.GetTestContext(); var modelState = testContext.ModelState; var model = new SoftwareViewModel { Category = "Technology", CompanyName = "Microsoft", Contact = "4258393231", Country = "USA", DatePurchased = new DateTime(2010, 10, 10), Name = "MVC", Price = 110, Version = "2" }; var controller = CreateController(testContext, testContext.MetadataProvider); // Act var result = controller.TryValidateModel(model); // Assert Assert.True(result); Assert.True(modelState.IsValid); var modelStateErrors = GetModelStateErrors(modelState); Assert.Empty(modelStateErrors); }
public void ModelState_IsInvalid_ForInvalidData_OnDerivedModel() { // Arrange var testContext = ModelBindingTestHelper.GetTestContext(); var modelState = testContext.ModelState; var model = new SoftwareViewModel { Category = "Technology", CompanyName = "Microsoft", Contact = "4258393231", Country = "UK", // Here the validate country is USA only DatePurchased = new DateTime(2010, 10, 10), Price = 110, Version = "2" }; var controller = CreateController(testContext, testContext.MetadataProvider); // Act var result = controller.TryValidateModel(model, prefix: "software"); // Assert Assert.False(result); Assert.False(modelState.IsValid); var modelStateErrors = GetModelStateErrors(modelState); Assert.Single(modelStateErrors); Assert.Equal("Product must be made in the USA if it is not named.", modelStateErrors["software"]); }
public ActionResult SoftwareAllReviewsByName(string id) { try { Session["calledPage"] = "R"; SoftwareViewModel softwareViewModel = null; SoftwareFilterEntity softwarereviewsFilter = new SoftwareFilterEntity { SoftwareName = id.Replace("-", " "), Rows = 0 }; softwareViewModel = new SoftwareService().GetAllSoftwareReviews(softwarereviewsFilter); if (softwareViewModel != null && (softwareViewModel.SoftwareList != null && softwareViewModel.SoftwareList.Count > 0)) { softwareViewModel.WebBaseUrl = _webBaseURL; return(View("~/Views/AllListPages/AllSoftwareReviewsList.cshtml", softwareViewModel)); } else { return(View("~/Views/Error/PageNotFound.cshtml")); } } catch (Exception ex) { return(null); } }
public ActionResult ReporteSoftwareContent(string idFacultad, string idLaboratorio, string nombreSoftware, string tipoSoftware) { SoftwareViewModel model = new SoftwareViewModel(); this.GetListaSoftwaresReporte(model, idFacultad, idLaboratorio, nombreSoftware, tipoSoftware); return(PartialView(model)); }
public ActionResult Edit([Bind(Include = "SoftwareId,Product,ProdDesc,AdvOverBeijer,AdditionalSpecs")] SoftwareViewModel software) { if (ModelState.IsValid) { _softwareService.Save(software); return(RedirectToAction("Index")); } return(View(software)); }
public SoftwareViewModel Save(SoftwareViewModel software) { var soft = FromSoft(software); db.Entry(soft).State = EntityState.Modified; db.SaveChanges(); return(SoftDto(soft)); }
public SoftwareViewModel Create(SoftwareViewModel software) { var soft = FromSoft(software); db.Softwares.Add(soft); db.SaveChanges(); soft.SoftwareId = software.SoftwareId; return(SoftDto(soft)); }
public IActionResult CategoryWiseSoftware(int id) { SoftwareViewModel SoftwareViewVM = new SoftwareViewModel { SingleSoftware = _work.Softwares.GetAllWithFeatureAndCategory(id), Client = _work.Client.GetAll() }; return(View(SoftwareViewVM)); }
public ActionResult SoftwareList(string SoftwareName, int SoftwareCategoryID, string sortby, int PageNo, int PageSize, int FirstPage, int LastPage, int OrderColumn) { SoftwareService softwareService = new SoftwareService(); SoftwareFilterEntity softwareFilter = new SoftwareFilterEntity { SoftwareName = SoftwareName, SoftwareCategoryId = SoftwareCategoryID, PageNo = PageNo, PageSize = PageSize, SortBy = sortby, UserID = Convert.ToInt32(Session["UserID"]), OrderColumn = OrderColumn }; SoftwareViewModel softwareViewModel = softwareService.GetSoftware(softwareFilter); softwareViewModel.WebBaseUrl = _webBaseUrl; softwareViewModel.PageCount = 0; softwareViewModel.PageNumber = PageNo; softwareViewModel.PageIndex = 1; if (softwareViewModel.SoftwareList.Count > 0) { softwareViewModel.PageCount = (softwareViewModel.SoftwareList[0].TotalCount + PageSize - 1) / PageSize; } if ((PageNo == FirstPage || PageNo == LastPage) && LastPage >= 5) { if (PageNo == FirstPage && PageNo != 1) { softwareViewModel.PageIndex = FirstPage - 1; } else if (PageNo == LastPage) { if (PageNo == softwareViewModel.PageCount) { softwareViewModel.PageIndex = (PageNo - 5) + 1; } else { softwareViewModel.PageIndex = FirstPage + 1; } } } else if (PageNo > LastPage && LastPage >= 5) { softwareViewModel.PageIndex = (PageNo - 5) + 1; } else if (PageNo >= FirstPage && PageNo <= LastPage) { softwareViewModel.PageIndex = FirstPage; } return(PartialView("_SoftwareList", softwareViewModel)); }
private static Software FromSoft(SoftwareViewModel software) { var soft = new Software { SoftwareId = software.SoftwareId, Product = software.Product, ProdDesc = software.ProdDesc, AdditionalSpecs = software.AdditionalSpecs, AdvOverBeijer = software.AdvOverBeijer }; return(soft); }
// GET: Software/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SoftwareViewModel software = _softwareService.FindById(id.Value); if (software == null) { return(HttpNotFound()); } return(View(software)); }
public ActionResult Index() { if (SecurityHelper.GetAdministradorID() > 0 && (SecurityHelper.GetAdministradorRol() == "Administrador General" || SecurityHelper.GetAdministradorRol() == "Técnico" || SecurityHelper.GetAdministradorRol() == "Practicante")) { SoftwareViewModel model = new SoftwareViewModel(); return(View(model)); } else { return(RedirectToAction("Index", "Login", new { Area = "" })); } }
public ActionResult Software() { if (SecurityHelper.GetAdministradorID() > 0 && (SecurityHelper.GetAdministradorRol() == "Administrador General" || SecurityHelper.GetAdministradorRol() == "Técnico" || SecurityHelper.GetAdministradorRol() == "Practicante")) { SoftwareViewModel model = new SoftwareViewModel(); model.ListaFacultadesLaboratorio = facultadDataAccess.GetListaFacultades(); model.ListaLaboratorios = laboratorioDataAccess.GetListaLaboratorios(); return(View(model)); } else { return(RedirectToAction("Index", "Login", new { Area = "" })); } }
public SoftwarePage() { InitializeComponent(); var softwareColumnWidth = Functions.GetConfig("SOFTWARE_VIEW_WIDTH_KEY", ""); ApplicationContext.SoftwareNameWidth = Functions.GetColumnWidth("Name", softwareColumnWidth); ApplicationContext.SoftwareVersionWidth = Functions.GetColumnWidth("Version", softwareColumnWidth); ApplicationContext.SoftwareCommentWidth = Functions.GetColumnWidth("Comment", softwareColumnWidth); ApplicationContext.SoftwareExecutableWidth = Functions.GetColumnWidth("Executable", softwareColumnWidth); ApplicationContext.SoftwareParametersWidth = Functions.GetColumnWidth("Parameters", softwareColumnWidth); ApplicationContext.SoftwareSizeWidth = Functions.GetColumnWidth("Size", softwareColumnWidth); SoftwareDataGrid.FieldLayouts.DataPresenter.GroupByAreaLocation = GroupByAreaLocation.None; Model = new SoftwareViewModel(this); Model.Refresh(); }
public object TryValidateModelSoftwareViewModelWithPrefix() { var softwareViewModel = new SoftwareViewModel { Category = "Technology", CompanyName = "Microsoft", Contact = "4258393231", Country = "UK", DatePurchased = new DateTime(2010, 10, 10), Price = 110, Version = "2" }; TryValidateModel(softwareViewModel, "software"); return(CreateValidationDictionary()); }
// GET: CompanyList public ActionResult SoftwareList(string id) { Session["calledPage"] = "S"; var urlSoftwareCategory = Convert.ToString(Request.Url.Segments[1]); var softwareService = new SoftwareService(); var softwareCategoryId = 0; if (Request.Url.Segments.Length > 2) { urlSoftwareCategory = urlSoftwareCategory.Replace("/", ""); } if (urlSoftwareCategory != string.Empty) { Session["SoftwareCategory"] = urlSoftwareCategory.ToString(); softwareCategoryId = new FocusAreaService().GetSoftwareCategoryID(urlSoftwareCategory); } SoftwareFilterEntity softwareFilter = new SoftwareFilterEntity { SoftwareName = "", SoftwareCategoryId = softwareCategoryId, PageNo = 1, PageSize = 25, SortBy = "DESC", UserID = Convert.ToInt32(Session["UserID"]), OrderColumn = 1, }; SoftwareViewModel softwareViewModel = softwareService.GetSoftware(softwareFilter); softwareViewModel.WebBaseUrl = _webBaseUrl; GetSoftwareCategoryHeadLine(urlSoftwareCategory, softwareViewModel); softwareViewModel.SoftwareCategoryId = softwareCategoryId.ToString(); softwareViewModel.PageCount = 0; softwareViewModel.PageNumber = 1; softwareViewModel.PageIndex = 1; softwareViewModel.TotalNoOfSoftwares = softwareViewModel.SoftwareList.Select(a => a.TotalCount).FirstOrDefault(); if (softwareViewModel.SoftwareList.Count > 0) { softwareViewModel.PageCount = (softwareViewModel.SoftwareList[0].TotalCount + 25 - 1) / 25; } return(View(softwareViewModel)); }
public ActionResult Softwares() { try { Session["calledPage"] = "N"; string softwareName = Convert.ToString(Request.Url.Segments[2]).Trim(); SoftwareViewModel softwareViewModel = null; if (softwareName != string.Empty) { Session["SoftwareName"] = softwareName; } if (CacheHandler.Exists(softwareName.ToLower())) { softwareViewModel = new SoftwareViewModel(); CacheHandler.Get(softwareName.ToLower(), out softwareViewModel); } else { SoftwareFilterEntity companyFilter = new SoftwareFilterEntity { SoftwareName = softwareName.Replace("-", " "), SortBy = "DESC", SoftwareCategoryId = 0, UserID = Convert.ToInt32(Session["UserID"]), PageNo = 1, PageSize = 10, OrderColumn = 1 }; softwareViewModel = new SoftwareService().GetSoftware(companyFilter); CacheHandler.Add(softwareViewModel, softwareName); } softwareViewModel.WebBaseUrl = _webBaseURL; return(View(softwareViewModel)); } catch (Exception) { return(null); } }
public ActionResult Editar(string idSoftware) { if (SecurityHelper.GetAdministradorID() > 0 && (SecurityHelper.GetAdministradorRol() == "Administrador General" || SecurityHelper.GetAdministradorRol() == "Técnico" || SecurityHelper.GetAdministradorRol() == "Practicante")) { SoftwareViewModel model = new SoftwareViewModel(); model.Software = softwareDataAccess.GetSoftwareById(int.Parse(idSoftware)); model.Software.IdFacultad = 1; model.Software.ListaSoftwareXCarrera = softwareDataAccess.GetListaSoftwareXCarreraByIdSoftware(int.Parse(idSoftware)); foreach (SoftwareXCarrera item in model.Software.ListaSoftwareXCarrera) { model.Software.CarrerasStringList += item.NombreCarrera + "\n"; } if (model.Software.CarrerasStringList.Length > 1) { model.Software.CarrerasStringList = model.Software.CarrerasStringList.Remove(model.Software.CarrerasStringList.Length - 1); } model.Software.ListaSoftwareXLaboratorio = softwareDataAccess.GetListaSoftwareXLaboratorioByIdSoftware(int.Parse(idSoftware)); foreach (SoftwareXLaboratorio item in model.Software.ListaSoftwareXLaboratorio) { model.Software.LaboratoriosStringList += item.NombreLaboratorio + "\n"; } if (model.Software.LaboratoriosStringList.Length > 1) { model.Software.LaboratoriosStringList = model.Software.LaboratoriosStringList.Remove(model.Software.LaboratoriosStringList.Length - 1); } model.ListaFacultadesLaboratorioForm = facultadDataAccess.GetListaFacultades(); return(View(model)); } else { return(RedirectToAction("Index", "Login", new { Area = "" })); } }
private void FormSoftwareCreateUpd_Load(object sender, EventArgs e) { if (id.HasValue) { try { SoftwareViewModel view = softwareLogic.Read(new SoftwareBindingModel { Id = id.Value })?[0]; if (view != null) { textBoxName.Text = view.Name; textBoxLicense.Text = view.License_type; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public ActionResult Edit(int id) { var powerSupply = _softwareService.GetSoftware(id); if (powerSupply == null) { return(NotFound()); } var model = new SoftwareViewModel() { Name = powerSupply.Name, Description = powerSupply.Description, ImagePath = "/Images/Software/" + powerSupply.Image, Price = powerSupply.Price, RecommendedRequiredRAM = powerSupply.RecommendedRequiredRAM, MinimiumRequiredRAM = powerSupply.MinimiumRequiredRAM, DiscVolume = powerSupply.DiscVolume, PublisherId = powerSupply.PublisherId, DeveloperId = powerSupply.DeveloperId, SoftwareCPURequirements = powerSupply.SoftwareCPURequirements, SoftwareVideoCardRequirements = powerSupply.SoftwareVideoCardRequirements }; var cpus = _cpuService.GetCPUs(); ViewBag.CPUs = new SelectList(cpus, "Id", "Name"); var videoCards = _videoCardService.GetVideoCards(); ViewBag.VideoCards = new SelectList(videoCards, "Id", "Name"); var publishers = _publisherService.GetPublishers(); ViewBag.Publishers = new SelectList(publishers, "Id", "Name"); var developers = _developerService.GetDevelopers(); ViewBag.Developers = new SelectList(developers, "Id", "Name"); return(View("Edit", model)); }
private void GetSoftwareCategoryHeadLine(string urlSoftwareCategory, SoftwareViewModel softwareViewModel) { int year = DateTime.Now.Year; string cachename = urlSoftwareCategory.Trim(); CategoryMetaTagsDetails metaTagObj; if (CacheHandler.Exists(cachename)) { metaTagObj = new CategoryMetaTagsDetails(); CacheHandler.Get(cachename, out metaTagObj); } else { metaTagObj = new CategoryMetaTagsDetails(); metaTagObj = new SoftwareService().GetSoftwareCategoryMetaTags(urlSoftwareCategory.Trim()); CacheHandler.Add(metaTagObj, cachename); } softwareViewModel.CategoryHeadLine = metaTagObj.Title.ToUpper(); softwareViewModel.Title = metaTagObj.TwitterTitle.Replace("{Year}", year.ToString()); softwareViewModel.MetaTag = SoftwareCategoryMetaTags(metaTagObj); }
public ActionResult ListaSoftwaresView() { if (SecurityHelper.GetAdministradorID() > 0 && (SecurityHelper.GetAdministradorRol() == "Administrador General" || SecurityHelper.GetAdministradorRol() == "Técnico" || SecurityHelper.GetAdministradorRol() == "Practicante")) { SoftwareViewModel model = new SoftwareViewModel(); model.ListaSoftware = softwareDataAccess.GetListaSoftwares(); if (model.ListaSoftware != null && model.ListaSoftware.Count > 0) { for (int i = 0; i < model.ListaSoftware.Count; i++) { model.ListaSoftware[i].ListaSoftwareXLaboratorio = softwareDataAccess.GetListaSoftwareXLaboratorioByIdSoftware(model.ListaSoftware[i].IdSoftware); model.ListaSoftware[i].ListaSoftwareXCarrera = softwareDataAccess.GetListaSoftwareXCarreraByIdSoftware(model.ListaSoftware[i].IdSoftware); if (model.ListaSoftware[i].ListaSoftwareXLaboratorio != null && model.ListaSoftware[i].ListaSoftwareXLaboratorio.Count > 0) { for (int j = 0; j < model.ListaSoftware[i].ListaSoftwareXLaboratorio.Count; j++) { Laboratorio laboratorio = new Laboratorio(); laboratorio.IdLaboratorio = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].IdLaboratorio; laboratorio.NombreLaboratorio = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].NombreLaboratorio; laboratorio.IdFacultad = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].IdFacultad; laboratorio.NombreFacultad = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].NombreFacultad; if (model.ListaSoftware[i].ListaLaboratorios == null || model.ListaSoftware[i].ListaLaboratorios.Count == 0) { model.ListaSoftware[i].ListaLaboratorios = new List <Laboratorio>(); } model.ListaSoftware[i].ListaLaboratorios.Add(laboratorio); } } if (model.ListaSoftware[i].ListaSoftwareXCarrera != null && model.ListaSoftware[i].ListaSoftwareXCarrera.Count > 0) { for (int k = 0; k < model.ListaSoftware[i].ListaSoftwareXCarrera.Count; k++) { Carrera carrera = new Carrera(); carrera.IdCarrera = model.ListaSoftware[i].ListaSoftwareXCarrera[k].IdCarrera; carrera.NombreCarrera = model.ListaSoftware[i].ListaSoftwareXCarrera[k].NombreCarrera; carrera.IdFacultad = model.ListaSoftware[i].ListaSoftwareXCarrera[k].IdFacultad; carrera.NombreFacultad = model.ListaSoftware[i].ListaSoftwareXCarrera[k].NombreFacultad; if (model.ListaSoftware[i].ListaCarreras == null || model.ListaSoftware[i].ListaCarreras.Count == 0) { model.ListaSoftware[i].ListaCarreras = new List <Carrera>(); } model.ListaSoftware[i].ListaCarreras.Add(carrera); } } model.ListaSoftware[i].IdFacultad = model.ListaSoftware[i].ListaLaboratorios[0].IdFacultad; model.ListaSoftware[i].NombreFacultad = model.ListaSoftware[i].ListaLaboratorios[0].NombreFacultad; } } return(PartialView(model)); } else { return(RedirectToAction("Index", "Login", new { Area = "" })); } }
public AppSearchDialogViewModel() { svm = Globals.SoftwareViewModel; }
public void GetListaSoftwaresReporte(SoftwareViewModel model, string idFacultad, string idLaboratorio, string nombreSoftware, string tipoSoftware) { if (!String.IsNullOrEmpty(idFacultad)) { model.ListaSoftware = softwareDataAccess.GetListaSoftwareByIdFacultad(int.Parse(idFacultad)); } else if (!String.IsNullOrEmpty(idLaboratorio)) { model.ListaSoftware = softwareDataAccess.GetListaSoftwareByIdLaboratorio(int.Parse(idLaboratorio)); } else if (!String.IsNullOrEmpty(nombreSoftware)) { model.ListaSoftware = softwareDataAccess.GetListaSoftwareByNombre(nombreSoftware); } else if (!String.IsNullOrEmpty(tipoSoftware)) { model.ListaSoftware = softwareDataAccess.GetListaSoftwareByTipo(tipoSoftware); } // Code from Software Controller if (model.ListaSoftware != null && model.ListaSoftware.Count > 0) { for (int i = 0; i < model.ListaSoftware.Count; i++) { model.ListaSoftware[i].ListaSoftwareXLaboratorio = softwareDataAccess.GetListaSoftwareXLaboratorioByIdSoftware(model.ListaSoftware[i].IdSoftware); model.ListaSoftware[i].ListaSoftwareXCarrera = softwareDataAccess.GetListaSoftwareXCarreraByIdSoftware(model.ListaSoftware[i].IdSoftware); if (model.ListaSoftware[i].ListaSoftwareXLaboratorio != null && model.ListaSoftware[i].ListaSoftwareXLaboratorio.Count > 0) { for (int j = 0; j < model.ListaSoftware[i].ListaSoftwareXLaboratorio.Count; j++) { Laboratorio laboratorio = new Laboratorio(); laboratorio.IdLaboratorio = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].IdLaboratorio; laboratorio.NombreLaboratorio = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].NombreLaboratorio; laboratorio.IdFacultad = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].IdFacultad; laboratorio.NombreFacultad = model.ListaSoftware[i].ListaSoftwareXLaboratorio[j].NombreFacultad; if (model.ListaSoftware[i].ListaLaboratorios == null || model.ListaSoftware[i].ListaLaboratorios.Count == 0) { model.ListaSoftware[i].ListaLaboratorios = new List <Laboratorio>(); } model.ListaSoftware[i].ListaLaboratorios.Add(laboratorio); } } if (model.ListaSoftware[i].ListaSoftwareXCarrera != null && model.ListaSoftware[i].ListaSoftwareXCarrera.Count > 0) { for (int k = 0; k < model.ListaSoftware[i].ListaSoftwareXCarrera.Count; k++) { Carrera carrera = new Carrera(); carrera.IdCarrera = model.ListaSoftware[i].ListaSoftwareXCarrera[k].IdCarrera; carrera.NombreCarrera = model.ListaSoftware[i].ListaSoftwareXCarrera[k].NombreCarrera; carrera.IdFacultad = model.ListaSoftware[i].ListaSoftwareXCarrera[k].IdFacultad; carrera.NombreFacultad = model.ListaSoftware[i].ListaSoftwareXCarrera[k].NombreFacultad; if (model.ListaSoftware[i].ListaCarreras == null || model.ListaSoftware[i].ListaCarreras.Count == 0) { model.ListaSoftware[i].ListaCarreras = new List <Carrera>(); } model.ListaSoftware[i].ListaCarreras.Add(carrera); } } model.ListaSoftware[i].IdFacultad = model.ListaSoftware[i].ListaLaboratorios[0].IdFacultad; model.ListaSoftware[i].NombreFacultad = model.ListaSoftware[i].ListaLaboratorios[0].NombreFacultad; } } }
public object ValidateSoftwareViewModelIncludingMetadata([FromBody] SoftwareViewModel software) { return(CreateValidationDictionary()); }
//[ValidateAntiForgeryToken] public ActionResult Edit(SoftwareViewModel model) { var software = _softwareService.GetSoftware(model.Id); if (software == null) { return(NotFound()); } if (model.SoftwareCPURequirements == null) { model.SoftwareCPURequirements = new List <SoftwareCPURequirement>(); } if (model.SoftwareVideoCardRequirements == null) { model.SoftwareVideoCardRequirements = new List <SoftwareVideoCardRequirement>(); } var newMinCpus = model.SoftwareCPURequirements.Where(m => m.RequirementTypeId == 1).Select(m => _cpuService.GetCPU(m.CPUId)); var newReqCpus = model.SoftwareCPURequirements.Where(m => m.RequirementTypeId == 2).Select(m => _cpuService.GetCPU(m.CPUId)); var newMinVC = model.SoftwareVideoCardRequirements.Where(m => m.RequirementTypeId == 1).Select(m => _videoCardService.GetVideoCard(m.VideoCardId)); var newReqVC = model.SoftwareVideoCardRequirements.Where(m => m.RequirementTypeId == 2).Select(m => _videoCardService.GetVideoCard(m.VideoCardId)); if (newMinCpus.Any(m => newReqCpus.Any(z => m.Frequency > z.Frequency || m.ThreadsNumber > z.ThreadsNumber || m.CoresNumber > z.CoresNumber))) { ModelState.AddModelError("SoftwareCPURequirements", "Мінімальні вимоги не можуть бути кращими за рекомендовані"); } if (newMinVC.Any(m => newReqVC.Any(z => m.Frequency > z.Frequency || m.MemoryFrequency > z.MemoryFrequency || m.MemorySize > z.MemorySize))) { ModelState.AddModelError("SoftwareVideoCardRequirements", "Мінімальні вимоги не можуть бути кращими за рекомендовані"); } if (model.MinimiumRequiredRAM > model.RecommendedRequiredRAM) { ModelState.AddModelError("MinimiumRequiredRAM", "Мінімальні вимоги не можуть бути кращими за рекомендовані"); } if (ModelState.IsValid) { software.Name = model.Name; software.Description = model.Description; software.MinimiumRequiredRAM = model.MinimiumRequiredRAM; software.RecommendedRequiredRAM = model.RecommendedRequiredRAM; software.Price = model.Price; software.DiscVolume = model.DiscVolume; software.PublisherId = model.PublisherId; software.DeveloperId = model.DeveloperId; if (model.Image != null) { var helper = new ImageHelper(_webHostEnvironment); var image = helper.GetUploadedFile(model.Image, "Software"); software.Image = image; } software.SoftwareCPURequirements = model.SoftwareCPURequirements.Select(m => new SoftwareCPURequirement() { CPUId = m.CPUId, RequirementTypeId = m.RequirementTypeId }).ToList(); software.SoftwareVideoCardRequirements = model.SoftwareVideoCardRequirements.Select(m => new SoftwareVideoCardRequirement() { VideoCardId = m.VideoCardId, RequirementTypeId = m.RequirementTypeId }).ToList(); var result = _softwareService.UpdateSoftware(software); model.Id = software.Id; model.Image = null; if (result.Succedeed) { return(View("../Catalog/Index", new { startView = "Software" })); } return(NotFound(result)); } var cpus = _cpuService.GetCPUs(); ViewBag.CPUs = new SelectList(cpus, "Id", "Name"); var videoCards = _videoCardService.GetVideoCards(); ViewBag.VideoCards = new SelectList(videoCards, "Id", "Name"); var publishers = _publisherService.GetPublishers(); ViewBag.Publishers = new SelectList(publishers, "Id", "Name"); var developers = _developerService.GetDevelopers(); ViewBag.Developers = new SelectList(developers, "Id", "Name"); return(View("Edit", model)); }
public async Task <IActionResult> InstallSoftware([FromBody] SoftwareViewModel model) { string result = _shellHelper.Bash("installOsintSoft.sh " + model.LinkProject + " " + model.Id); return(Ok(result)); }