public StandardModel UpdateStandard(StandardModel data, string name) { var entity = _standardRepository.GetQuery() .FirstOrDefault(t => t.Id == data.Id); if (entity == null) { return(null); } entity.NAME = data.Name; entity.TYPE = data.Type; entity.URL = data.Url; entity.LASTUPDATEDBY = name; entity.LASTUPDATEDDATE = DateTime.Now; _standardRepository.Update(entity); return(new StandardModel { Id = entity.Id, Name = entity.NAME, Type = entity.TYPE, Url = entity.URL, CreatedBy = entity.CREATEDBY, CreatedDate = entity.CREATEDDATE }); }
//Update Standard (async) public async Task <StandardDTO> UpdateStandardAsync(StandardDTO modelDTO) { try { using (var unitOfWork = unitOfWorkFactory.Create()) { StandardModel model = _Mapper_ToModel.Map <StandardDTO, StandardModel>(modelDTO); bool result = unitOfWork.StandardRepository.Update(model); StandardDTO modelRTN = null; if (result) { await unitOfWork.SaveChangesAsync(); modelRTN = _Mapper_ToDTO.Map <StandardModel, StandardDTO>(model); } return(modelRTN); } } catch (Exception ex) { LogException(ex); throw ex; } }
public async Task GetStandardAsync_Calls_StandardService_GetStandard() { var standardCode = "547"; var standardName = "Broadcast and Media Systems Technician"; var StandardSectorCode = "11"; var standard = new StandardModel { StandardCode = standardCode, StandardName = standardName, StandardSectorCode = StandardSectorCode }; var serviceMock = new Mock <IStandardService>(); serviceMock .Setup(m => m.GetStandard(standardCode)) .ReturnsAsync(standard); var controller = new StandardController(serviceMock.Object); var result = await controller.GetStandardAsync(standardCode); serviceMock.Verify(m => m.GetStandard(standardCode), Times.Once); result.Should().BeEquivalentTo(standard); }
public static void InsertRecord(StandardModel standard) { var sqlToInsertStandard = "INSERT INTO [dbo].[Standards]" + "([StandardUId]" + ", [IFateReferenceNumber]" + ", [Version]" + ", [Title]" + ", [Level]" + ", [Status]" + ", [TypicalDuration]" + ", [MaxFunding]" + ", [IsActive]" + ", [ProposedTypicalDuration]" + ", [ProposedMaxFunding])" + "VALUES " + "(@StandardUId" + ", @iFateReferenceNumber" + ", @version" + ", @title" + ", @level" + ", @status" + ", @typicalDuration" + ", @maxFunding" + ", @isActive" + ", @proposedTypicalDuration" + ", @proposedMaxFunding)"; DatabaseService.Execute(sqlToInsertStandard, standard); }
public bool Update(StandardModel entity) { try { entity.School = _dbContext.Schools.FirstOrDefault(x => x.SchoolId == entity.SchoolId); entity.Year = _dbContext.Years.FirstOrDefault(x => x.YearId == entity.YearId); var currentEntity = _dbContext.Set <StandardModel>().AsQueryable().FirstOrDefault(x => x.StandardId == entity.StandardId); if (currentEntity == null) { return(false); } currentEntity.StandardName = entity.StandardName; currentEntity.SchoolId = entity.SchoolId; currentEntity.School = entity.School; currentEntity.YearId = entity.YearId; currentEntity.Year = entity.Year; return(true); } catch (Exception ex) { LogException(ex); throw ex; } }
public async Task GetStandard_Calls_Client_Get() { var standardCode = "547"; var standardName = "Broadcast and Media Systems Technician"; var StandardSectorCode = "11"; var standard = new StandardModel { StandardCode = standardCode, StandardName = standardName, StandardSectorCode = StandardSectorCode }; var parameters = new Dictionary <string, object> { { StandardCodeParameterName, standardCode } }; var clientServiceMock = new Mock <IClientService>(); clientServiceMock .Setup(m => m.GetAsync <StandardModel>(Url, parameters)) .ReturnsAsync(standard); var service = new StandardApiService(clientServiceMock.Object); var result = await service.GetStandard(standardCode); clientServiceMock.Verify(m => m.GetAsync <StandardModel>(Url, parameters), Times.Once); result.Should().BeEquivalentTo(standard); }
// GET: Standards/Details/5 public async Task <IActionResult> Details(decimal?id) { if (id == null) { return(NotFound()); } var standard = await _context.Standard .Include(s => s.Parent) .FirstOrDefaultAsync(m => m.Id == id); //if (standard == null) //{ // return NotFound(); //} //return View(standard); StandardModel standardModel = new StandardModel(); standardModel.Id = standard.Id; standardModel.Description = standard.Description; standardModel.Name = standard.Name; standardModel.ParentId = standard.ParentId; standardModel.ThumbnailTemp = standard.ThumbnailTemp; standardModel.Product = new HashSet <Product>(from s in _context.Standard join sl in _context.StandardLink on s.Id equals sl.StandardId join p in _context.Product on sl.ProductId equals p.Id where s.Id == id select sl.Product).Take(16); return(View(standardModel)); }
public static void GetFilePaths(ref TableMakerModel tableMakerModel) { var project = tableMakerModel.Project; var programs = tableMakerModel.Programs; var testers = tableMakerModel.Testers; OCVModel ocvModel = new OCVModel(); RCModel rcModel = new RCModel(); MiniModel miniModel = new MiniModel(); StandardModel standardModel = new StandardModel(); AndroidModel androidModel = new AndroidModel(); tableMakerModel.OCVModel = ocvModel; tableMakerModel.RCModel = rcModel; tableMakerModel.MiniModel = miniModel; tableMakerModel.StandardModel = standardModel; tableMakerModel.AndroidModel = androidModel; ocvModel.FilePath = OCVTableMaker.GetOCVTableFilePath(project); rcModel.FilePath = RCTableMaker.GetRCTableFilePath(project); List <string> strFilePaths; GetDriverFilePaths(project.BatteryType.Manufacturer, project.BatteryType.Name, project.AbsoluteMaxCapacity.ToString(), "mini", out strFilePaths); miniModel.FilePaths = strFilePaths; GetDriverFilePaths(project.BatteryType.Manufacturer, project.BatteryType.Name, project.AbsoluteMaxCapacity.ToString(), "standard", out strFilePaths); standardModel.FilePaths = strFilePaths; GetDriverFilePaths(project.BatteryType.Manufacturer, project.BatteryType.Name, project.AbsoluteMaxCapacity.ToString(), "android", out strFilePaths); androidModel.FilePaths = strFilePaths; }
public void UpdateLod(List <int> activePassIds, MyLodStrategyPreprocessor preprocessor) { MyLodStrategyInfo lodStrategyInfo = StandardModel.GetLodStrategyInfo(); Vector3D cameraPos = MyRender11.Environment.Matrices.CameraPosition; Vector3D instancePos = m_transformStrategy.GetCoreTranslation(); m_lodStrategy.SmoothResolve(lodStrategyInfo, MyCommon.FrameCounter, MyCommon.LastFrameDelta(), cameraPos, instancePos, activePassIds, preprocessor); }
public void UpdateStandard(string model) { var data = model.JsonTo <StandardModel>(); StandardModel result = standardService.UpdateStandard(data, CurrentUser.Name); IndexData(new List <StandardModel> { result }); }
public static void GetStandardModel(OCVModel ocvModel, RCModel rcModel, ref StandardModel standardModel) { standardModel.iOCVVolt = ocvModel.iOCVVolt; standardModel.fCTABase = rcModel.fCTABase; standardModel.fCTASlope = rcModel.fCTASlope; standardModel.listfCurr = rcModel.listfCurr; standardModel.listfTemp = rcModel.listfTemp; standardModel.outYValue = rcModel.outYValue; }
public PartialViewResult StandardGrid() { StandardModel L = new StandardModel(); //use this for delegating authorization by roles //List<StandardModel> model = L.SelectAllViewerStandardsByRoles(Roles.GetRolesForUser().ToList()); List <StandardModel> model = L.SelectAllStandards(); int c = model.Count; return(PartialView(model)); }
internal static void GenerateStandardDriver(StandardModel standardModel, Project project) { List <string> strFilePaths = standardModel.FilePaths; List <string> strHHeaderComments; UInt32 uErr = 0; TableMakerService.InitializeHeaderInfor(ref uErr, project.BatteryType.Manufacturer, project.BatteryType.Name, project.AbsoluteMaxCapacity.ToString(), project.LimitedChargeVoltage.ToString(), project.CutoffDischargeVoltage.ToString(), out strHHeaderComments); var OutFolder = $@"{GlobalSettings.RootPath}{project.BatteryType.Name}\{project.Name}\{GlobalSettings.ProductFolderName}"; GenerateCHFiles(ref uErr, OutFolder, strFilePaths[0], strFilePaths[1], strHHeaderComments, standardModel.iOCVVolt, project.VoltagePoints, standardModel.listfTemp, standardModel.listfCurr, standardModel.outYValue, standardModel.fCTABase, standardModel.fCTASlope); }
public bool SetInstanceMaterial(string materialName, MyInstanceMaterial instanceMaterial) { int instanceMaterialOffset = StandardModel.GetInstanceMaterialOffset(materialName); if (instanceMaterialOffset == -1) { return(false); } m_instanceMaterials.Set(instanceMaterialOffset, instanceMaterial); return(true); }
public void endpoint_invocation___model_lookup_tests() { var controller = new StandardController(); var uriModel = new StandardModel { IntProp = 204 }; var bodyModel = new StandardNullableModel { IntProp = 301 }; var context = new ApiRequestContext { RequestAborted = new CancellationToken(false), Request = new ApiRequestInfo { InvocationContext = new ApiInvocationContext { ControllerInstance = controller, UriModel = uriModel, BodyModel = bodyModel, } } }; // Test model lookup methods var models = context.Request.InvocationContext.Models(); models.Should().NotBeNull(); models.Should().HaveCount(2); models.Should().Contain(uriModel); models.Should().Contain(bodyModel); var foundUriModel = context.Request.InvocationContext.Models <StandardModel>().FirstOrDefault(); foundUriModel.Should().NotBeNull(); foundUriModel.Should().BeSameAs(uriModel); var foundBodyModel = context.Request.InvocationContext.Models <StandardNullableModel>().FirstOrDefault(); foundBodyModel.Should().NotBeNull(); foundBodyModel.Should().BeSameAs(bodyModel); var baseModels = context.Request.InvocationContext.Models <StandardModelBase>(); baseModels.Should().NotBeNull(); baseModels.Should().HaveCount(2); }
public void Remove(StandardModel entity) { try { _dbContext.Entry(entity).State = EntityState.Deleted; //return await (_dbContext.SaveChangesAsync()); } catch (Exception ex) { LogException(ex); throw ex; } }
public bool SetInstanceMaterialEmissivity(string materialName, float emissivity) { int instanceMaterialOffset = StandardModel.GetInstanceMaterialOffset(materialName); if (instanceMaterialOffset == -1) { return(false); } MyInstanceMaterial instanceMaterial = m_instanceMaterials.Get(instanceMaterialOffset); instanceMaterial.Emissivity = emissivity; m_instanceMaterials.Set(instanceMaterialOffset, instanceMaterial); return(true); }
/// <summary> /// Initializes a new instance of the <see cref="Upload Sample Paper Page"/> class. /// </summary> public UploadSamplePaper() { IsLoading = true; Device.BeginInvokeOnMainThread(async() => { try { _StandardList = await StandardModel.GetStandard(); UploadSamplePaperLayout(); } catch (Exception ex) { } }); }
/// <summary> /// Initializes a new instance of the <see cref="Enter Student Mark Page"/> class. /// </summary> public EnterStudentMark() { IsLoading = true; Device.BeginInvokeOnMainThread(async() => { try { _StandardList = await StandardModel.GetStandard(); EnterStudentMarkLayout(); } catch (Exception ex) { } }); }
public ActionResult SaveNewStandard(StandardModel standardModel) { Standard standard = new Standard(); if (ModelState.IsValid) { standard.standardName = standardModel.StandardName; standard.description = standardModel.Description; SDBE.Standards.Add(standard); SDBE.SaveChanges(); } return(Json("", JsonRequestBehavior.AllowGet)); }
public bool SetInstanceMaterialColorMult(string materialName, Vector3 colorMult) { int instanceMaterialOffset = StandardModel.GetInstanceMaterialOffset(materialName); if (instanceMaterialOffset == -1) { return(false); } MyInstanceMaterial instanceMaterial = m_instanceMaterials.Get(instanceMaterialOffset); instanceMaterial.ColorMult = colorMult; m_instanceMaterials.Set(instanceMaterialOffset, instanceMaterial); return(true); }
public void Add(StandardModel entity) { try { entity.School = _dbContext.Schools.FirstOrDefault(x => x.SchoolId == entity.SchoolId); entity.Year = _dbContext.Years.FirstOrDefault(x => x.YearId == entity.YearId); _dbContext.Entry(entity).State = EntityState.Added; } catch (Exception ex) { LogException(ex); throw ex; } }
public ActionResult Edit(StandardModel standardModel) { Standard standard = new Standard(); if (ModelState.IsValid) { standard.standardID = standardModel.StandardID; standard.standardName = standardModel.StandardName; standard.description = standardModel.Description; SDBE.Entry(standard).State = EntityState.Modified; SDBE.SaveChanges(); } return(Json("", JsonRequestBehavior.AllowGet)); }
/// <summary> /// Initializes a new instance of the <see cref="Student BehaviourNotice Page"/> class. /// </summary> public StudentBehaviourNotice() { IsLoading = true; Device.BeginInvokeOnMainThread(async() => { try { IsLoading = true; _StandardList = await StandardModel.GetStandard(); StudentBehaviourLayout(); } catch (Exception ex) { } }); }
/// <summary> /// Initializes a new instance of the <see cref="FillUpAttendance"/> class. /// </summary> public FillUpAttendance() { IsLoading = true; Device.BeginInvokeOnMainThread(async() => { try { IsLoading = true; _StandardList = await StandardModel.GetStandard(); FillUpAttendanceLayout(); } catch (Exception ex) { } }); }
public async Task endpoint_invocation___returns_true_for_api_response_and_uri_and_body_parameter_and_extra_parameters_endpoint() { var controller = new StandardController(); var uriModel = new StandardModel { IntProp = 204 }; var bodyModel = new StandardNullableModel { IntProp = 301 }; var context = new ApiRequestContext { RequestAborted = new CancellationToken(false), Request = new ApiRequestInfo { InvocationContext = new ApiInvocationContext { ControllerInstance = controller, UriModel = uriModel, BodyModel = bodyModel } }, Routing = new ApiRoutingInfo { Route = new ApiRoutingItem { Location = new ApiEndpointLocation( controller: controller.GetType(), methodInfo: controller.GetType().GetMethod(nameof(controller.DefaultFullApiResponseEndpointWithUriParameterAndBodyParameterAndExtraParameters)), httpMethod: null) } } }; var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false); processed.Should().BeTrue(); context.Response.Should().NotBeNull(); context.Response.StatusCode.Should().Be(200); context.Response.ResponseObject.Should().BeOfType <int>(); context.Response.ResponseObject.Should().Be(301); }
public async Task GetStandard_Returns_Valid_Standard() { var standardCode = "547"; var standardName = "Broadcast and Media Systems Technician"; var StandardSectorCode = "11"; var azureStandard = new StandardModel { StandardCode = standardCode, StandardName = standardName, StandardSectorCode = StandardSectorCode }; var apiStandard = new Models.StandardModel { StandardCode = standardCode, StandardName = standardName, StandardSectorCode = StandardSectorCode }; var mapperMock = new Mock <IMapper <StandardModel, Models.StandardModel> >(); mapperMock.Setup(m => m.Map(azureStandard)).Returns(apiStandard); var indexServiceMock = new Mock <IStandardIndexService>(); var azureServiceMock = new Mock <IAzureService>(); azureServiceMock .Setup(m => m.GetAsync <StandardModel>(It.IsAny <IStandardIndexService>(), standardCode)) .ReturnsAsync(azureStandard); var queryServiceMock = new Mock <IODataQueryService>(); var searchTermFormattingServiceMock = new Mock <ISearchTermFormattingService>(); var service = new AzureStandardService( indexServiceMock.Object, mapperMock.Object, azureServiceMock.Object, queryServiceMock.Object, searchTermFormattingServiceMock.Object); var result = await service.GetStandard(standardCode); azureServiceMock.Verify(m => m.GetAsync <StandardModel>(It.IsAny <IStandardIndexService>(), standardCode), Times.Once); result.Should().BeSameAs(apiStandard); }
//Find Single Standard base on "term" (async) public async Task <StandardDTO> SearchSingleStandardByIdAsync(int Id) { try { using (var unitOfWork = unitOfWorkFactory.Create()) { StandardModel model = await Task.Run(() => unitOfWork.StandardRepository.GetSingleOrDefaultStandard(x => x.StandardId == Id)); return(_Mapper_ToDTO.Map <StandardModel, StandardDTO>(model)); } } catch (Exception ex) { LogException(ex); throw ex; } }
public void Map_Returns_Valid_Model() { var model = new StandardModel { StandardCode = "547", StandardName = "Broadcast and Media Systems Technician", StandardSectorCode = "11", StandardSectorCodeDesc2 = "Newspaper and Broadcast Media", Version = 1, NotionalEndLevel = "5", EffectiveFrom = new DateTime(2020, 03, 06), EffectiveTo = new DateTime(2022, 1, 1), LastDateStarts = new DateTime(2021, 1, 1), SectorSubjectAreaTier1 = "4", SectorSubjectAreaTier1Desc = "Engineering and Manufacturing Technolgies", SectorSubjectAreaTier2 = "4.10", SectorSubjectAreaTier2Desc = "Engineering", IntegratedDegreeStandard = "Y", OtherBodyApprovalRequired = "N" }; var commonComponentMapperMock = new Mock <IMapper <CommonComponentModel, Models.CommonComponentModel> >(); var standardFundingModelMapperMock = new Mock <IMapper <StandardFundingModel, Models.StandardFundingModel> >(); var standardApprenticeModelMapperMock = new Mock <IMapper <StandardApprenticeshipFundingModel, Models.StandardApprenticeshipFundingModel> >(); var aimMapperMock = new Mock <IMapper <RelatedLearningAimModel, Models.RelatedLearningAimModel> >(); var mapper = new AzureStandardMapper(standardFundingModelMapperMock.Object, standardApprenticeModelMapperMock.Object, commonComponentMapperMock.Object, aimMapperMock.Object); var result = mapper.Map(model); result.StandardCode.Should().Be(model.StandardCode); result.StandardName.Should().Be(model.StandardName); result.StandardSectorCode.Should().Be(model.StandardSectorCode); result.StandardSectorCodeDesc2.Should().Be(model.StandardSectorCodeDesc2); result.Version.Should().Be(model.Version); result.EffectiveFrom.Should().Be(model.EffectiveFrom); result.EffectiveTo.Should().Be(model.EffectiveTo); result.NotionalEndLevel.Should().Be(model.NotionalEndLevel); result.LastDateStarts.Should().Be(model.LastDateStarts); result.SectorSubjectAreaTier1.Should().Be(model.SectorSubjectAreaTier1); result.SectorSubjectAreaTier1Desc.Should().Be(model.SectorSubjectAreaTier1Desc); result.SectorSubjectAreaTier2.Should().Be(model.SectorSubjectAreaTier2); result.SectorSubjectAreaTier2Desc.Should().Be(model.SectorSubjectAreaTier2Desc); result.IntegratedDegreeStandard.Should().Be(model.IntegratedDegreeStandard); result.OtherBodyApprovalRequired.Should().Be(model.OtherBodyApprovalRequired); }
//Add Standard (async) public async Task <int> AddStandardAsync(StandardDTO modelDTO) { try { using (var unitOfWork = unitOfWorkFactory.Create()) { StandardModel model = _Mapper_ToModel.Map <StandardDTO, StandardModel>(modelDTO); unitOfWork.StandardRepository.Add(model); //unitOfWork.Repository.Add<StandardModel>(model); await unitOfWork.SaveChangesAsync(); return(model.StandardId); } } catch (Exception ex) { LogException(ex); throw ex; } }