public override void List() { var model = GetListModel(); var b = TinyMapper.Map <TestA, TestB>(model); }
private void RegisterMappings() { TinyMapper.Bind <Cfp, CfpData>(); TinyMapper.Bind <CfpData, Cfp>(); TinyMapper.Bind <List <Cfp>, List <CfpData> >(); }
/// <summary> /// 新增疾病编码 /// </summary> /// <param name="dto"></param> public void Post(JbbmCreationDTO dto) { _jbbmService.Create(TinyMapper.Map <YdhlJbbm>(dto)); }
public IHttpActionResult PostSAL(Sals tmpsal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } int assessmentId = Auth.AssessmentForUser(); TinyMapper.Bind <Sals, STANDARD_SELECTION>(); STANDARD_SELECTION sTANDARD_SELECTION = db.STANDARD_SELECTION.Where(x => x.Assessment_Id == assessmentId).FirstOrDefault(); if (sTANDARD_SELECTION != null) { sTANDARD_SELECTION = TinyMapper.Map <Sals, STANDARD_SELECTION>(tmpsal, sTANDARD_SELECTION); } else { sTANDARD_SELECTION = TinyMapper.Map <STANDARD_SELECTION>(tmpsal); } sTANDARD_SELECTION.Assessment_Id = assessmentId; db.Entry(sTANDARD_SELECTION).State = EntityState.Modified; LevelManager lm = new LevelManager(assessmentId, db); lm.SaveOtherLevels(assessmentId, tmpsal); lm.Init(sTANDARD_SELECTION); if (tmpsal.SelectedSALOverride) { lm.SaveSALLevel(tmpsal.Selected_Sal_Level); } try { db.SaveChanges(); StandardRepository sr = new StandardRepository(assessmentId, lm, new StandardManager(), new AssessmentModeData(db, assessmentId), new StandardSpecficLevelRepository(db)); sr.Confidence_Level = tmpsal.CLevel; sr.Integrity_Level = tmpsal.ILevel; sr.Availability_Level = tmpsal.ALevel; // save the newly-calculated overall value if (!tmpsal.SelectedSALOverride) { tmpsal.Selected_Sal_Level = sr.Selected_Sal_Level; lm.SaveSALLevel(tmpsal.Selected_Sal_Level); } return(Ok(tmpsal)); } catch (DbUpdateConcurrencyException dbe) { if (!STANDARD_SELECTIONExists(assessmentId)) { return(NotFound()); } else { throw dbe; } } catch (Exception e) { CSETWeb_Api.Helpers.ElmahWrapper.LogAndReportException(e, Request, HttpContext.Current); } return(StatusCode(HttpStatusCode.NoContent)); }
public List <Customer> MapWithTinyMapper() { return(TinyMapper.Map <List <Customer> >(_customerDtos)); }
static JbxxController() { TinyMapper.Bind <JbxxCreationDTO, YdhlJbxx>(); }
/// <summary> /// Note that for now we are limiting the number of questions to two. /// </summary> /// <param name="userid">THIS VALUE SHOULD NEVER COME FROM THE POST OR URL ONLY THE AUTHTOKEN</param> /// <param name="user"></param> public void UpdateUser(int userid, string PrimaryEmail, CreateUser user) { using (CSET_Context db = new CSET_Context()) { var dbuser = db.USERS.Where(x => x.UserId == userid).FirstOrDefault(); TinyMapper.Map(user, dbuser); var details = db.USER_DETAIL_INFORMATION.Where(x => x.PrimaryEmail == PrimaryEmail).FirstOrDefault(); if (details != null) { TinyMapper.Map <CreateUser, USER_DETAIL_INFORMATION>(user, details); } /** * Some things to think about * they have existing questions and are updating them * they don't have existing questions and are reusing and existing provided question * they are giving us a new custom question */ // RKW - 9-May-2018 - Commenting out the question logic until we know if we are doing it or not #region Security Question Logic //List<int> processedQuestions = new List<int>(); //Dictionary<int, USER_SECURITY_QUESTIONS> existingQuestions = (from a in db.USER_SECURITY_QUESTIONS // join b in db.SECURITY_QUESTION on a.SecurityQuestionID equals b.SecurityQuestionId // where a.UserId == userid // select a // ).ToDictionary(x => x.SecurityQuestionID, x => x); //USER_SECURITY_QUESTIONS question; //if(existingQuestions.TryGetValue(user.CustomQuestion.SecurityQuestionId, out question)) //{ // question.SecurityAnswer = user.CustomQuestion.Answer; // processedQuestions.Add(user.CustomQuestion.SecurityQuestionId); //} //else //{ // SECURITY_QUESTION sq= new SECURITY_QUESTION() // { // SecurityQuestion = user.CustomQuestion.SecurityQuestion, // IsCustomQuestion = true // }; // db.USER_SECURITY_QUESTIONS.Add(new USER_SECURITY_QUESTIONS() // { // SecurityAnswer = user.CustomQuestion.Answer, // SECURITY_QUESTION = sq, // UserId = userid // }); // db.SECURITY_QUESTION.Add(sq); //} //if(existingQuestions.TryGetValue(user.SelectedQuestion.SecurityQuestionId,out question)) //{ // question.SecurityAnswer = user.SelectedQuestion.Answer; // processedQuestions.Add(user.SelectedQuestion.SecurityQuestionId); //} //else //{ // db.USER_SECURITY_QUESTIONS.Add(new USER_SECURITY_QUESTIONS() // { // SecurityQuestionID = user.SelectedQuestion.SecurityQuestionId, // SecurityAnswer = user.SelectedQuestion.Answer, // UserId = userid // }); //} ////remove all the others; //foreach(KeyValuePair<int,USER_SECURITY_QUESTIONS> pair in existingQuestions) //{ // if (!processedQuestions.Contains(pair.Key)) // { // db.USER_SECURITY_QUESTIONS.Remove(pair.Value); // } //} #endregion db.SaveChanges(); } }
public void Bind <TSource, TTarget>() { TinyMapper.Bind <TSource, TTarget>(); }
/// <summary> /// Construct a response containing the applicable requirement questions with their answers. /// </summary> /// <param name="requirements"></param> /// <param name="answers"></param> /// <returns></returns> private QuestionResponse BuildResponse(List <RequirementPlus> requirements, List <FullAnswer> answers, List <DomainAssessmentFactor> domains) { List <QuestionGroup> groupList = new List <QuestionGroup>(); QuestionGroup g = new QuestionGroup(); QuestionSubCategory sg = new QuestionSubCategory(); QuestionAnswer qa = new QuestionAnswer(); string currentGroupHeading = string.Empty; string currentSubcategoryHeading = string.Empty; try { foreach (var dbRPlus in requirements) { var dbR = dbRPlus.Requirement; // Make sure there are no leading or trailing spaces - it will affect the tree structure that is built dbR.Standard_Category = dbR.Standard_Category == null ? null : dbR.Standard_Category.Trim(); dbR.Standard_Sub_Category = dbR.Standard_Sub_Category == null ? null : dbR.Standard_Sub_Category.Trim(); // If the Standard_Sub_Category is null (like CSC_V6), default it to the Standard_Category if (dbR.Standard_Sub_Category == null) { dbR.Standard_Sub_Category = dbR.Standard_Category; } if (dbR.Standard_Category != currentGroupHeading) { g = new QuestionGroup() { GroupHeadingId = dbR.Question_Group_Heading_Id, GroupHeadingText = dbR.Standard_Category, StandardShortName = dbRPlus.SetShortName, }; if (domains.Any(x => x.AssessmentFactorName == g.GroupHeadingText)) { g.DomainName = domains.FirstOrDefault(x => x.AssessmentFactorName == g.GroupHeadingText) .DomainName; } groupList.Add(g); currentGroupHeading = g.GroupHeadingText; } // new subcategory if (dbR.Standard_Sub_Category != currentSubcategoryHeading) { sg = new QuestionSubCategory() { SubCategoryId = 0, SubCategoryHeadingText = dbR.Standard_Sub_Category, GroupHeadingId = g.GroupHeadingId }; g.SubCategories.Add(sg); currentSubcategoryHeading = dbR.Standard_Sub_Category; } FullAnswer answer = answers.Where(x => x.a.Question_Or_Requirement_Id == dbR.Requirement_Id).FirstOrDefault(); qa = new QuestionAnswer() { DisplayNumber = dbR.Requirement_Title, QuestionId = dbR.Requirement_Id, QuestionText = dbR.Requirement_Text.Replace("\r\n", "<br/>").Replace("\n", "<br/>").Replace("\r", "<br/>"), Answer = answer?.a.Answer_Text, AltAnswerText = answer?.a.Alternate_Justification, Comment = answer?.a.Comment, Feedback = answer?.a.Feedback, MarkForReview = answer?.a.Mark_For_Review ?? false, Reviewed = answer?.a.Reviewed ?? false, MaturityLevel = ReqMaturityLevel(dbR.Requirement_Id), SetName = dbRPlus.SetName, Is_Component = answer?.a.Is_Component ?? false, Is_Requirement = answer?.a.Is_Requirement ?? true }; if (answer != null) { TinyMapper.Map <VIEW_QUESTIONS_STATUS, QuestionAnswer>(answer.b, qa); } qa.ParmSubs = GetTokensForRequirement(qa.QuestionId, (answer != null) ? answer.a.Answer_Id : 0); sg.Questions.Add(qa); } QuestionResponse resp = new QuestionResponse { QuestionGroups = groupList, ApplicationMode = this.applicationMode }; resp.QuestionCount = new QuestionsManager(this._assessmentId).NumberOfQuestions(); resp.RequirementCount = this.NumberOfRequirements(); // Get the overall risk level var acetDash = new ACETDashboardManager().LoadDashboard(this._assessmentId); resp.OverallIRP = acetDash.SumRiskLevel; if (acetDash.Override > 0) { resp.OverallIRP = acetDash.Override; } BuildComponentsResponse(resp); return(resp); } catch (Exception e) { throw e; } }
public TTarget Map <TSource, TTarget>(TSource source, TTarget target = default(TTarget)) { return(TinyMapper.Map(source, target)); }
public TTarget Map <TTarget>(object source) { return(TinyMapper.Map <TTarget>(source)); }
public void Bind <TSource, TTarget>(Action <IBindingConfig <TSource, TTarget> > config) { TinyMapper.Bind(config); }
static EntityMappingStrategyFactory() { TinyMapper.Bind <Car, CarSummary>(); }
public override void Nomal() { var model = GetNomalModel(); var b = TinyMapper.Map <TestA, TestB>(model); }
static TwdController() { TinyMapper.Bind <TwdCreationDTO, YdhlTwd>(); }
public Benchmark() { TinyMapper.Bind <SourceTest, TargetTest>(); }
public TOut Map <TIn, TOut>(TIn instance) { return(TinyMapper.Map <TOut>(instance)); }
public static ClassA TinyMapperMap(ClassB classB) { return(TinyMapper.Map <ClassA>(classB)); }
/// <summary> /// 新增病人 /// </summary> /// <param name="dto"></param> public void Post(JbxxCreationDTO dto) { _jbxxService.Create(TinyMapper.Map <YdhlJbxx>(dto)); }
static BryzxxController() { TinyMapper.Bind <BryzxxCreationDTO, YdhlBryzxx>(); }
private BrzdController() { TinyMapper.Bind <BrzdCreationDTO, YdhlBrzd>(); }
public static TTo Map <TFrom, TTo>(TFrom from) where TTo : class { return(from == null ? null : TinyMapper.Map <TTo>(from)); }
public IActionResult Get(int id) { var item = DbContext.Items.Where(i => i.Id == id).FirstOrDefault(); return(new JsonResult(TinyMapper.Map <ItemViewModel>(item), DefaultJsonSettings)); }
public ActionResult Create( [Bind( Include = "Assets,Segments,ID,OrderNumber,CreatedAt,CampaignName,BroadcastDate,RepresentativeName,RepresentativeEmail,ReBroadCast,ReBroadcastDate,Price,TestingUrgency,GeoDetails,Demographics,Quantity,FromLine,SubjectLine,IsPersonalization,IsMatchback,IsSuppression,IsOpenPixel,OpenPixelUrl,BannerUrl,WhiteLabel,OptOut,SpecialInstructions,IsAddViewInBrowser,IsAddOptOut,DataFileQuantity,IsOmniOrder,OmniDeployDate,Impressions,ChannelTypes")] CampaignVm campaignVm) { if (ModelState.IsValid) { try { string userName = string.IsNullOrEmpty(LoggedInUser?.UserName) ? UsersList.FirstOrDefault().Text : LoggedInUser?.UserName; TinyMapper.Bind <CampaignVm, Campaign>(config => { config.Ignore(x => x.Segments); config.Ignore(x => x.ChannelTypes); }); var campaign = TinyMapper.Map <Campaign>(campaignVm); char c2 = 'A'; foreach (var segmentVm in campaignVm.Segments) { var segment = TinyMapper.Map <CampaignSegment>(segmentVm); segment.Id = Guid.NewGuid(); segment.CreatedAt = DateTime.Now; segment.OrderNumber = "" + campaignVm.OrderNumber; segment.SegmentNumber = campaignVm.OrderNumber + "" + c2++; campaign.Segments.Add(segment); } campaign.Id = Guid.NewGuid(); campaign.CreatedAt = DateTime.Now; campaign.CreatedBy = userName; campaign.OrderNumber = campaignVm.OrderNumber.ToString(); campaign.IP = Request.ServerVariables["REMOTE_ADDR"]; campaign.Browser = Request.UserAgent; campaign.OS = Environment.OSVersion.Platform + " " + Environment.OSVersion.VersionString; campaign.Referrer = Request.UrlReferrer.AbsolutePath; campaign.ChannelTypes = campaignVm.ChannelTypes == null ? null : string.Join(",", campaignVm.ChannelTypes); campaign.Assets.Id = Guid.NewGuid(); campaign.Assets.CampaignId = campaign.Id; campaign.Assets.CreatedAt = DateTime.Now; campaign.Assets.CreatedBy = userName; Db.Campaigns.Add(campaign); Db.SaveChanges(); BackgroundJob.Enqueue(() => CampaignProcessor.ProcessNewOrder(campaign.OrderNumber, userName)); ForceOrders = true; TempData["Success"] = "Order #: " + campaign.OrderNumber + " , Campaign " + campaign.CampaignName + " has been submitted sucessfully."; } catch (Exception ex) { TempData["Error"] = "This is error while creating order." + ex.Message; } return(RedirectToAction("Index")); } campaignVm.ChannelTypes = campaignVm.ChannelTypes ?? new List <ChannelType> { }; ViewBag.TestingUrgency = new SelectList(EnumHelper.GetEnumTextValues(typeof(TestingUrgency)), "Value", "Text", campaignVm.TestingUrgency); ViewBag.WhiteLabel = new SelectList(CustomersWithWLList, "Value", "Text", LoggedInUser?.Customer?.WhiteLabel); return(View(campaignVm)); }
public int RunImportManualPortion(UploadAssessmentModel model, int currentUserId, string primaryEmail , CSET_Context db) { //create the new assessment //copy each of the items to the table //as the copy occurs change to the current assessment_id //update the answer id's Dictionary <int, DOCUMENT_FILE> oldIdToNewDocument = new Dictionary <int, DOCUMENT_FILE>(); AssessmentManager man = new AssessmentManager(); AssessmentDetail detail = man.CreateNewAssessmentForImport(currentUserId); int _assessmentId = detail.Id; Dictionary <int, int> oldAnswerId = new Dictionary <int, int>(); Dictionary <int, ANSWER> oldIdNewAnswer = new Dictionary <int, ANSWER>(); Dictionary <String, int> oldUserNewUser = db.USERS.ToDictionary(x => x.PrimaryEmail, y => y.UserId); foreach (var a in model.jASSESSMENTS) { var item = db.ASSESSMENTS.Where(x => x.Assessment_Id == _assessmentId).FirstOrDefault(); if (item != null) { item.Assets = a.Assets; item.Charter = a.Charter; item.CreditUnionName = a.CreditUnionName; item.IRPTotalOverride = a.IRPTotalOverride; item.IRPTotalOverrideReason = a.IRPTotalOverrideReason; item.MatDetail_targetBandOnly = a.MatDetail_targetBandOnly != null ? a.MatDetail_targetBandOnly : false; db.SaveChanges(); } } // go through the assessment contacts and // if the contact does exist create it then add the id // if the contact does exist update the id foreach (var a in model.jASSESSMENT_CONTACTS.Where(x => x.PrimaryEmail != primaryEmail)) { var item = TinyMapper.Map <ASSESSMENT_CONTACTS>(a); item.Assessment_Id = _assessmentId; item.PrimaryEmail = a.PrimaryEmail; int userid; if (oldUserNewUser.TryGetValue(a.PrimaryEmail, out userid)) { item.UserId = userid; } else { item.UserId = null; } db.ASSESSMENT_CONTACTS.Add(item); } db.SaveChanges(); foreach (var a in model.jUSER_DETAIL_INFORMATION) { if (db.USER_DETAIL_INFORMATION.Where(x => x.Id == a.Id).FirstOrDefault() == null) { var userInfo = TinyMapper.Map <USER_DETAIL_INFORMATION>(a); userInfo.FirstName = String.IsNullOrWhiteSpace(a.FirstName) ? "First Name" : a.FirstName; userInfo.LastName = String.IsNullOrWhiteSpace(a.LastName) ? "Last Name" : a.LastName; db.USER_DETAIL_INFORMATION.Add(userInfo); foreach (var b in a.jADDRESSes) { var item = TinyMapper.Map <ADDRESS>(b); item.AddressType = "Imported"; db.ADDRESS.Add(item); } db.SaveChanges(); } } return(_assessmentId); #region RKW Oct '19 - These table conversions are being commented out, so that the GenericImporter can do it. //foreach (var a in model.jANSWER) //{ // a.Assessment_Id = _assessmentId; // a.Old_Answer_Id = a.Answer_Id; // a.Answer_Id = 0; //} //db.SaveChanges(); //var objBulk = new BulkUploadToSql<jANSWER>() //{ // InternalStore = model.jANSWER, // TableName = "ANSWER", // CommitBatchSize = 1000, // ConnectionString = ((Microsoft.EntityFrameworkCore.DbContext)db).Database.GetDbConnection().ConnectionString //}; //objBulk.Commit(); //oldAnswerId = db.ANSWER.Where(x => x.Assessment_Id == _assessmentId).ToDictionary(x => x.Old_Answer_Id ?? 0, y => y.Answer_Id); //oldIdNewAnswer = db.ANSWER.Where(x => x.Assessment_Id == _assessmentId).ToDictionary(x => x.Old_Answer_Id ?? 0, y => y); //if (model.jSTANDARD_SELECTION.Count > 0) //{ // foreach (var a in model.jSTANDARD_SELECTION) // { // var item = TinyMapper.Map<STANDARD_SELECTION>(a); // item.Assessment_Id = _assessmentId; // db.STANDARD_SELECTION.Add(item); // } //} //else //{ // db.STANDARD_SELECTION.Add(new STANDARD_SELECTION() // { // Application_Mode = AssessmentModeData.QUESTIONS_BASED_APPLICATION_MODE, // Selected_Sal_Level = Constants.SAL_LOW, // Assessment_Id = _assessmentId, // Last_Sal_Determination_Type = Constants.SIMPLE_SAL, // Is_Advanced = false // }); //} //foreach (var a in model.jASSESSMENT_SELECTED_LEVELS) //{ // var item = TinyMapper.Map<ASSESSMENT_SELECTED_LEVELS>(a); // item.Assessment_Id = _assessmentId; // db.ASSESSMENT_SELECTED_LEVELS.Add(item); //} //foreach (var a in model.jAVAILABLE_STANDARDS) //{ // var item = TinyMapper.Map<AVAILABLE_STANDARDS>(a); // item.Assessment_Id = _assessmentId; // db.AVAILABLE_STANDARDS.Add(item); //} //foreach (var a in model.jCNSS_CIA_JUSTIFICATIONS) //{ // var item = TinyMapper.Map<CNSS_CIA_JUSTIFICATIONS>(a); // item.Assessment_Id = _assessmentId; // db.CNSS_CIA_JUSTIFICATIONS.Add(item); //} //foreach (var a in model.jCUSTOM_BASE_STANDARDS) { var item = TinyMapper.Map<CUSTOM_BASE_STANDARDS>(a); db.CUSTOM_BASE_STANDARDS.Add(item); } //foreach (var a in model.jCUSTOM_QUESTIONAIRES) { var item = TinyMapper.Map<CUSTOM_QUESTIONAIRES>(a); db.CUSTOM_QUESTIONAIRES.Add(item); } //foreach (var a in model.jCUSTOM_QUESTIONAIRE_QUESTIONS) //{ // var item = TinyMapper.Map<CUSTOM_QUESTIONAIRE_QUESTIONS>(a); db.CUSTOM_QUESTIONAIRE_QUESTIONS.Add(item); //} //foreach (var a in model.jCUSTOM_STANDARD_BASE_STANDARD) //{ // var item = TinyMapper.Map<CUSTOM_STANDARD_BASE_STANDARD>(a); db.CUSTOM_STANDARD_BASE_STANDARD.Add(item); //} //foreach (var a in model.jDEMOGRAPHICS) //{ // var item = TinyMapper.Map<DEMOGRAPHICS>(a); // item.Assessment_Id = _assessmentId; // if ((a.IndustryId == 0) || (a.SectorId == 0)) // { // //what do we want to do for a default? // } // else // db.DEMOGRAPHICS.Add(item); //} ////this needs the answers inserted first ////then the documents and finally ////we can associate documents and answers ////look at adding a reference to the answer to jDocument_File ////then as we iterate through the answers and documents keep the references //foreach (var a in model.jDOCUMENT_FILE) //{ // var item = TinyMapper.Map<DOCUMENT_FILE>(a); // oldIdToNewDocument.Add(a.Document_Id, item); // item.Assessment_Id = _assessmentId; // item.Document_Id = 0; // db.DOCUMENT_FILE.Add(item); //} //db.SaveChanges(); //foreach (var a in model.jDOCUMENT_ANSWERS) //{ // var item = oldIdToNewDocument[a.Document_Id]; // db.DOCUMENT_ANSWERS.Add(new DOCUMENT_ANSWERS() // { // Answer_Id = oldIdNewAnswer[a.Answer_Id].Answer_Id, // Document_Id = item.Document_Id // }); //} //Dictionary<int, FINDING> idToFinding = new Dictionary<int, FINDING>(); //foreach (var a in model.jFINDING) //{ // var item = TinyMapper.Map<FINDING>(a); // item.Importance_Id = item.Importance_Id == 0 ? 1 : item.Importance_Id; // item.Answer_Id = oldAnswerId[a.Answer_Id]; // idToFinding.Add(a.Finding_Id, item); // db.FINDING.Add(item); //} //var AcontactID = db.ASSESSMENT_CONTACTS.Where(x => x.UserId == currentUserId).FirstOrDefault(); //if (AcontactID != null)//if we dont have a current user we are in trouble //{ // int acid = AcontactID.Assessment_Contact_Id; // foreach (var a in model.jFINDING_CONTACT) // { // db.FINDING_CONTACT.Add(new FINDING_CONTACT() // { // Assessment_Contact_Id = a.Assessment_Contact_Id == 0 ? acid : a.Assessment_Contact_Id, // Finding_Id = idToFinding[a.Finding_Id].Finding_Id, // Id = a.Old_Contact_Id // }); // } //} //foreach (var a in model.jFRAMEWORK_TIER_TYPE_ANSWER) //{ // var item = TinyMapper.Map<FRAMEWORK_TIER_TYPE_ANSWER>(a); // item.Assessment_Id = _assessmentId; // db.FRAMEWORK_TIER_TYPE_ANSWER.Add(item); //} //foreach (var a in model.jGENERAL_SAL) //{ // var item = TinyMapper.Map<GENERAL_SAL>(a); // item.Assessment_Id = _assessmentId; // db.GENERAL_SAL.Add(item); //} //foreach (var a in model.jINFORMATION) //{ // var info = db.INFORMATION.Where(x => x.Id == _assessmentId).FirstOrDefault(); // if (info != null) // { // TinyMapper.Map(a, info); // info.Id = _assessmentId; // db.SaveChanges(); // } // else // { // var item = TinyMapper.Map<INFORMATION>(a); // item.Id = _assessmentId; // db.INFORMATION.Add(item); // } // db.ASSESSMENTS.Where(x => x.Assessment_Id == _assessmentId).First().Assessment_Date = a.Assessment_Date; // db.SaveChanges(); //} //foreach (var a in model.jNIST_SAL_INFO_TYPES) //{ // var item = TinyMapper.Map<NIST_SAL_INFO_TYPES>(a); // item.Assessment_Id = _assessmentId; // db.NIST_SAL_INFO_TYPES.Add(item); //} //foreach (var a in model.jNIST_SAL_QUESTION_ANSWERS) //{ // var item = TinyMapper.Map<NIST_SAL_QUESTION_ANSWERS>(a); // item.Question_Answer = item.Question_Answer ?? "No"; // item.Assessment_Id = _assessmentId; // db.NIST_SAL_QUESTION_ANSWERS.Add(item); // db.SaveChanges(); //} //foreach (var a in model.jPARAMETER_VALUES) //{ // var item = TinyMapper.Map<PARAMETER_VALUES>(a); // item.Answer_Id = oldAnswerId[a.Answer_Id]; // db.PARAMETER_VALUES.Add(item); //} //foreach (var a in model.jPARAMETER_ASSESSMENTs) //{ // var item = TinyMapper.Map<PARAMETER_ASSESSMENT>(a); // item.Assessment_ID = _assessmentId; // db.PARAMETER_ASSESSMENT.Add(item); //} //foreach (var a in model.jSUB_CATEGORY_ANSWERS) //{ // var item = TinyMapper.Map<SUB_CATEGORY_ANSWERS>(a); // item.Assessement_Id = _assessmentId; // if ((a.Question_Group_Heading_Id > 0) && (a.Universal_Sub_Category_Id > 0)) // { // var header = db.UNIVERSAL_SUB_CATEGORY_HEADINGS.Where(x => x.Question_Group_Heading_Id == a.Question_Group_Heading_Id && x.Universal_Sub_Category_Id == a.Universal_Sub_Category_Id).FirstOrDefault(); // if (header != null) // { // item.Heading_Pair_Id = header.Heading_Pair_Id; // } // else // { // try // { // var tempHeading = db.UNIVERSAL_SUB_CATEGORIES.Where(x => x.Universal_Sub_Category_Id == a.Universal_Sub_Category_Id).FirstOrDefault(); // if (tempHeading != null) // { // var adding = new UNIVERSAL_SUB_CATEGORY_HEADINGS() // { // Display_Radio_Buttons = false, // Question_Group_Heading_Id = a.Question_Group_Heading_Id, // Universal_Sub_Category_Id = a.Universal_Sub_Category_Id, // Sub_Heading_Question_Description = null // }; // //see if we can create the record // db.UNIVERSAL_SUB_CATEGORY_HEADINGS.Add(adding); // db.SaveChanges(); // item.Heading_Pair_Id = adding.Heading_Pair_Id; // } // } // catch // { // //silent throw away NOT MY FAVORITE // //but ok because there is nothing else we can do here. // } // } // } // if (!String.IsNullOrWhiteSpace(a.Question_Group_Heading) && !String.IsNullOrWhiteSpace(a.Universal_Sub_Category)) // { // var header = db.vQUESTION_HEADINGS.Where(x => x.Question_Group_Heading == a.Question_Group_Heading && x.Universal_Sub_Category == a.Universal_Sub_Category).FirstOrDefault(); // if (header == null) // {//try by id's // var header2 = db.UNIVERSAL_SUB_CATEGORY_HEADINGS.Where(x => x.Question_Group_Heading_Id == a.Question_Group_Heading_Id && x.Universal_Sub_Category_Id == a.Universal_Sub_Category_Id).FirstOrDefault(); // if (header2 != null) // item.Heading_Pair_Id = header2.Heading_Pair_Id; // } // else // { // item.Heading_Pair_Id = header.Heading_Pair_Id; // } // } // if (item.Heading_Pair_Id > 0) // db.SUB_CATEGORY_ANSWERS.Add(item); //} //// //// NCUA data //// //List<int> supportedDocIds = db.REQUIRED_DOCUMENTATION.Select(d => d.Documentation_Id).ToList(); //foreach (var a in model.jASSESSMENTS_REQUIRED_DOCUMENTATION) //{ // if (supportedDocIds.Contains(a.Documentation_Id)) // { // var item = TinyMapper.Map<ASSESSMENTS_REQUIRED_DOCUMENTATION>(a); // item.Assessment_Id = _assessmentId; // db.ASSESSMENTS_REQUIRED_DOCUMENTATION.Add(item); //} //} //foreach (var a in model.jFINANCIAL_ASSESSMENT_VALUES) //{ // var item = TinyMapper.Map<FINANCIAL_ASSESSMENT_VALUES>(a); // item.Assessment_Id = _assessmentId; // db.FINANCIAL_ASSESSMENT_VALUES.Add(item); //} //foreach (var a in model.jFINANCIAL_HOURS) //{ // var item = TinyMapper.Map<FINANCIAL_HOURS>(a); // item.Assessment_Id = _assessmentId; // db.FINANCIAL_HOURS.Add(item); //} //foreach (var a in model.jASSESSMENT_IRP_HEADER) //{ // var item = TinyMapper.Map<ASSESSMENT_IRP_HEADER>(a); // item.ASSESSMENT_ID = _assessmentId; // db.ASSESSMENT_IRP_HEADER.Add(item); //} //foreach (var a in model.jASSESSMENT_IRP) //{ // var item = TinyMapper.Map<ASSESSMENT_IRP>(a); // item.Assessment_Id = _assessmentId; // item.Answer_Id = 0; // db.ASSESSMENT_IRP.Add(item); //} //try //{ // db.SaveChanges(); //} //catch (Exception e) //{ // throw e; //} #endregion }
public static IServiceCollection AddTinyMapper(this IServiceCollection services) { TinyMapper.Bind <AppSettings, MainViewModel>(); TinyMapper.Bind <MainViewModel, AppSettings>(); return(services); }
static JbbmController() { TinyMapper.Bind <JbbmCreationDTO, YdhlJbbm>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, DbSeeder dbSeeder) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseDefaultFiles(); app.UseStaticFiles(new StaticFileOptions() { OnPrepareResponse = context => { //Disable Caching for Static Files context.Context.Response.Headers["Cache-Control"] = Configuration["StaticFiles:Headers:Cache-Control"]; context.Context.Response.Headers["Pragma"] = Configuration["StaticFiles:Headers:Pragma"]; context.Context.Response.Headers["Expires"] = Configuration["StaticFiles:Headers:Expires"]; } }); // Add a custom Jwt Provider to generate Tokens app.UseJwtProvider(); app.UseIdentity(); // Add external authentication middleware below. // To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseFacebookAuthentication(new FacebookOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, AppId = Configuration["Authentication:Facebook:AppId"], AppSecret = Configuration["Authentication:Facebook:AppSecret"], CallbackPath = "/signin-facebook", Scope = { "email" } }); app.UseGoogleAuthentication(new GoogleOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, ClientId = Configuration["Authentication:Google:ClientId"], ClientSecret = Configuration["Authentication:Google:ClientSecret"], CallbackPath = "/signin-google", Scope = { "email" } }); app.UseTwitterAuthentication(new TwitterOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, ConsumerKey = Configuration["Authentication:Twitter:ConsumerKey"], ConsumerSecret = Configuration["Authentication:Twitter:ConsumerSecret"], CallbackPath = "/signin-twitter" }); app.UseOpenIddict(); // Add the Jwt Bearer Header Authentication to validate Tokens app.UseJwtBearerAuthentication(new JwtBearerOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, RequireHttpsMetadata = false, Authority = Configuration["Authentication:OpenIddict:Authority"], TokenValidationParameters = new TokenValidationParameters() { //IssuerSigningKey = JwtProvider.SecurityKey, //ValidateIssuerSigningKey = true, //ValidIssuer = JwtProvider.Issuer, ValidateIssuer = false, ValidateAudience = false } }); // Add MVC to the pipeline app.UseMvc(); //Tiny Maper binding config TinyMapper.Bind <Item, ItemViewModel>(); // Seed the DB if needed try { dbSeeder.SeedAsync().Wait(); } catch (AggregateException e) { throw new Exception(e.ToString()); } }
/// <summary> /// The passed in finding is the source, if the ID does not exist it will create it. /// this will also push the data to the database and retrieve any auto identity id's /// </summary> /// <param name="f">source finding</param> /// <param name="context">the data context to work on</param> public FindingViewModel(Finding f, CSET_Context context) { //get all the contacts in this assessment //get all the contexts on this finding this.webFinding = f; if (f.IsFindingEmpty()) { return; } this.context = context; this.dbFinding = context.FINDING .Include(x => x.FINDING_CONTACT) .Where(x => x.Answer_Id == f.Answer_Id && x.Finding_Id == f.Finding_Id) .FirstOrDefault(); if (dbFinding == null) { var finding = new FINDING { Answer_Id = f.Answer_Id, Summary = f.Summary, Impact = f.Impact, Issue = f.Issue, Recommendations = f.Recommendations, Vulnerabilities = f.Vulnerabilities, Resolution_Date = f.Resolution_Date }; this.dbFinding = finding; context.FINDING.Add(finding); } TinyMapper.Map(f, this.dbFinding); int importid = (f.Importance_Id == null) ? 1 : (int)f.Importance_Id; this.dbFinding.Importance_ = context.IMPORTANCE.Where(x => x.Importance_Id == importid).FirstOrDefault();//note that 1 is the id of a low importance if (f.Finding_Contacts != null) { foreach (FindingContact fc in f.Finding_Contacts) { if (fc.Selected) { FINDING_CONTACT tmpC = dbFinding.FINDING_CONTACT.Where(x => x.Assessment_Contact_Id == fc.Assessment_Contact_Id).FirstOrDefault(); if (tmpC == null) { dbFinding.FINDING_CONTACT.Add(new FINDING_CONTACT() { Assessment_Contact_Id = fc.Assessment_Contact_Id, Finding_Id = f.Finding_Id }); } } else { FINDING_CONTACT tmpC = dbFinding.FINDING_CONTACT.Where(x => x.Assessment_Contact_Id == fc.Assessment_Contact_Id).FirstOrDefault(); if (tmpC != null) { dbFinding.FINDING_CONTACT.Remove(tmpC); } } } } }
public override void Complex() { var model = GetComplexModel(); var b = TinyMapper.Map <TestA, TestB>(model); }