public static void Link(ActionBy actionBy, Affiliation affiliation) { actionBy.Affiliation = affiliation; actionBy.AffiliationID = affiliation.AffiliationID; affiliation.ActionBies.Add(actionBy); }
public static void Link(Core.Action action, ActionBy actionBy) { action.ActionBies.Add(actionBy); actionBy.Action = action; actionBy.ActionID = action.ActionID; }
public Post( int postId, int userId, int textBookId, ActionBy actionBy, int price, BookCondition bookCondition, int isTransacting, int isActive, int isDeleted, DateTime createdDate, DateTime modifiedDate) { PostId = postId; UserId = userId; TextBookId = textBookId; ActionBy = actionBy; Price = price; BookCondition = bookCondition; IsTransacting = isTransacting; IsActive = isActive; IsDeleted = isDeleted; CreatedDate = createdDate; ModifiedDate = modifiedDate; }
public TransactionComment(int commentId, string comment, ActionBy actionBy, Transaction transaction) { CommentId = commentId; Comment = comment; TransactionId = transaction.TransactionId; Details = new TransactionDetailModel(transaction); }
public JsonResult newComment(string comment, ActionBy commentor, int userId, int OtherUserId, int transactionId) { Comment newComment = new Comment( -1, comment, userId, commentor, transactionId, 1, 0, DateTime.Now, DateTime.Now ); CommentHandler.createComment(newComment); return Json(""); }
public JsonResult newComment(string comment, ActionBy commentor, int userId, int OtherUserId, int transactionId) { Comment newComment = new Comment( -1, comment, userId, commentor, transactionId, 1, 0, DateTime.Now, DateTime.Now ); CommentHandler.createComment(newComment); return(Json("")); }
public Comment( int commentId, string comment, int userId, ActionBy actionBy, int transactionId, int isActive, int isDeleted, DateTime createdDate, DateTime modifiedDate ) { CommentId = commentId; UserId = userId; ActionBy = actionBy; TransactionId = transactionId; this.comment = comment; IsActive = isActive; IsDeleted = isDeleted; CreatedDate = createdDate; ModifiedDate = modifiedDate; CommentatorProfile = ProfileHandler.GetProfile(UserId); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 35, Configuration.FieldSeparator), Id, OrderControl, PlacerOrderNumber?.ToDelimitedString(), FillerOrderNumber?.ToDelimitedString(), PlacerGroupNumber?.ToDelimitedString(), OrderStatus, ResponseFlag, QuantityTiming != null ? string.Join(Configuration.FieldRepeatSeparator, QuantityTiming) : null, ParentOrder?.ToDelimitedString(), DateTimeOfTransaction.HasValue ? DateTimeOfTransaction.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, EnteredBy != null ? string.Join(Configuration.FieldRepeatSeparator, EnteredBy.Select(x => x.ToDelimitedString())) : null, VerifiedBy != null ? string.Join(Configuration.FieldRepeatSeparator, VerifiedBy.Select(x => x.ToDelimitedString())) : null, OrderingProvider != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingProvider.Select(x => x.ToDelimitedString())) : null, EnterersLocation?.ToDelimitedString(), CallBackPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, CallBackPhoneNumber.Select(x => x.ToDelimitedString())) : null, OrderEffectiveDateTime.HasValue ? OrderEffectiveDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, OrderControlCodeReason?.ToDelimitedString(), EnteringOrganization?.ToDelimitedString(), EnteringDevice?.ToDelimitedString(), ActionBy != null ? string.Join(Configuration.FieldRepeatSeparator, ActionBy.Select(x => x.ToDelimitedString())) : null, AdvancedBeneficiaryNoticeCode?.ToDelimitedString(), OrderingFacilityName != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingFacilityName.Select(x => x.ToDelimitedString())) : null, OrderingFacilityAddress != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingFacilityAddress.Select(x => x.ToDelimitedString())) : null, OrderingFacilityPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingFacilityPhoneNumber.Select(x => x.ToDelimitedString())) : null, OrderingProviderAddress != null ? string.Join(Configuration.FieldRepeatSeparator, OrderingProviderAddress.Select(x => x.ToDelimitedString())) : null, OrderStatusModifier?.ToDelimitedString(), AdvancedBeneficiaryNoticeOverrideReason?.ToDelimitedString(), FillersExpectedAvailabilityDateTime.HasValue ? FillersExpectedAvailabilityDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, ConfidentialityCode?.ToDelimitedString(), OrderType?.ToDelimitedString(), EntererAuthorizationMode?.ToDelimitedString(), ParentUniversalServiceIdentifier?.ToDelimitedString(), AdvancedBeneficiaryNoticeDate.HasValue ? AdvancedBeneficiaryNoticeDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null, AlternatePlacerOrderNumber != null ? string.Join(Configuration.FieldRepeatSeparator, AlternatePlacerOrderNumber.Select(x => x.ToDelimitedString())) : null, OrderWorkflowProfile != null ? string.Join(Configuration.FieldRepeatSeparator, OrderWorkflowProfile.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public Core.Action Map(ESDATModel esdatModel) { var entity = Draft(esdatModel); // Feature Actions var featureAction = _sampleCollectionFactory.FeatureActionMapper.Map(esdatModel); ODM2EntityLinker.Link(entity, featureAction); // Sampling Feature var samplingFeature = _sampleCollectionFactory.SamplingFeatureMapper.Map(esdatModel); ODM2EntityLinker.Link(featureAction, samplingFeature); // Dataset Guid // Generate and set guid for this import batch var guid = Guid.NewGuid(); _sampleCollectionFactory.DatasetMapper.Guid = guid; _chemistryFactory.DatasetMapper.Guid = guid; _chemistryFactory.DatasetMapper.BackingStore = _sampleCollectionFactory.DatasetMapper.BackingStore; // Results // Each Feature Action can contain many results (Samples) foreach (SampleFileData sample_ in esdatModel.SampleFileData) { _sampleCollectionFactory.ResultMapper.Sample = sample_; Result result = _sampleCollectionFactory.ResultMapper.Map(esdatModel); ODM2EntityLinker.Link(featureAction, result); // Unit var unit = _sampleCollectionFactory.UnitMapper.Map(esdatModel); ODM2EntityLinker.Link(result, unit); // Variable var variable = _sampleCollectionFactory.VariableMapper.Map(esdatModel); ODM2EntityLinker.Link(result, variable); // Datasets Result { var datasetsResult = _sampleCollectionFactory.DatasetsResultMapper.Map(esdatModel); ODM2EntityLinker.Link(result, datasetsResult); var dataset = _sampleCollectionFactory.DatasetMapper.Map(esdatModel); ODM2EntityLinker.Link(datasetsResult, dataset); } // Processing Level var processingLevel = _sampleCollectionFactory.ProcessingLevelMapper.Map(esdatModel); ODM2EntityLinker.Link(result, processingLevel); // Result Extension Property Values { var properties = new Dictionary <string, string>(); properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleCode] = sample_.SampleCode; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyFieldID] = sample_.FieldID; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleDepth] = sample_.SampleDepth.ToString(); properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyMatrixType] = sample_.MatrixType; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleType] = sample_.SampleType; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyParentSample] = sample_.ParentSample; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySDG] = sample_.SDG; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyLabSampleID] = sample_.LabSampleID; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyComments] = sample_.Comments; properties[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyLabReportNumber] = sample_.LabReportNumber; foreach (var property in properties) { var extensionProperty = _sampleCollectionFactory.ExtensionPropertyMapper.Map(property.Key); var propertyID = extensionProperty.PropertyID; var propertyValue = property.Value; var resultExtensionPropertyValue = _sampleCollectionFactory.ResultExtensionPropertyValueMapper.Map(propertyID, propertyValue); ODM2EntityLinker.Link(resultExtensionPropertyValue, extensionProperty); ODM2EntityLinker.Link(result, resultExtensionPropertyValue); } } // Related Actions // Create a new related Action for each chemistry file // Assume that 1 unique sample maps to one or more chemistry files var chemistryData = esdatModel.ChemistryData.Where(x => x.SampleCode.Equals(sample_.SampleCode)); foreach (ChemistryFileData chemistry_ in chemistryData) { _chemistryFactory.ActionMapper.ParentAction = entity; _chemistryFactory.ActionMapper.SampleFileData = sample_; var chemistryAction = _chemistryFactory.ActionMapper.Map(esdatModel, chemistry_); _chemistryFactory.RelatedActionMapper.SetRelationship(entity, _WQDefaultValueProvider.ActionRelationshipTypeCVSampleCollection, chemistryAction); var relatedAction = _chemistryFactory.RelatedActionMapper.Map(esdatModel); ODM2EntityLinker.Link(entity, relatedAction); } } // Action Bies { ActionBy actionBy = _sampleCollectionFactory.ActionByMapper.Map(esdatModel); ODM2EntityLinker.Link(entity, actionBy); var person = _chemistryFactory.PersonMapper.Map(esdatModel); _chemistryFactory.AffiliationMapper.Person = person; var affiliation = _chemistryFactory.AffiliationMapper.Map(esdatModel); ODM2EntityLinker.Link(actionBy, affiliation); } // Method { var method = _sampleCollectionFactory.MethodMapper.Map(esdatModel); ODM2EntityLinker.Link(entity, method); var organization = _sampleCollectionFactory.OrganizationMapper.Map(esdatModel); ODM2EntityLinker.Link(method, organization); } return(entity); }
public static Post findMatchingPost(Post post) { Post matchingPost = null; try { var counterparty = post.ActionBy == ActionBy.Buyer ? ActionBy.Seller : ActionBy.Buyer; string query = String.Format("UserId <> {0} AND TextBookId = {1} AND ActionBy = {2} " + "AND IsTransacting = 0 AND IsActive = 1 AND IsDeleted = 0", post.UserId, post.TextBookId, (int)counterparty ); List <SortColumn> sortColumns = new List <SortColumn>(); if (post.ActionBy == ActionBy.Buyer) //buyer { query += String.Format("AND Price <= {0} AND BookCondition >= {1}", post.Price, (int)post.BookCondition ); sortColumns.Add(new SortColumn("Price", "ASC")); } else //seller { query += String.Format("AND Price >= {0} AND BookCondition <= {1}", post.Price, (int)post.BookCondition ); sortColumns.Add(new SortColumn("Price", "DESC")); } DataAccess da = new DataAccess(); DataTable dt = da.select(query, "Posts", NumRows: 1, SortColumns: sortColumns); if (dt != null && dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; int postId = Convert.ToInt32(row["PostId"]); int profileId = Convert.ToInt32(row["UserId"]); int textBookId = Convert.ToInt32(row["TextBookId"]); ActionBy actionBy = (ActionBy)Convert.ToInt32(row["ActionBy"]); int price = Convert.ToInt32(row["Price"]); BookCondition bookCondition = (BookCondition)Convert.ToInt32(row["BookCondition"]); int isTransacting = Convert.ToInt32(row["IsTransacting"]); int isActive = Convert.ToInt32(row["IsActive"]); int isDeleted = Convert.ToInt32(row["IsDeleted"]); DateTime createdDate = (DateTime)row["CreatedDate"]; DateTime modifiedDate = (DateTime)row["ModifiedDate"]; matchingPost = new Post( postId, profileId, textBookId, actionBy, price, bookCondition, isTransacting, isActive, isDeleted, createdDate, modifiedDate ); } } catch (Exception ex) { Console.Write(ex.Message + " " + ex.StackTrace); } return(matchingPost); }
private ICollection<ActionBy> CloneActionBies(Hatfield.EnviroData.Core.Action previousVersionAction, Hatfield.EnviroData.Core.Action newVersionAction) { if (previousVersionAction.ActionBies == null) { return null; } else { var clonedNewActionBies = new List<ActionBy>(); foreach(var actionByInPreviousVersion in previousVersionAction.ActionBies) { var newActionBy = new ActionBy(); newActionBy.Action = newVersionAction; newActionBy.Affiliation = actionByInPreviousVersion.Affiliation; newActionBy.AffiliationID = actionByInPreviousVersion.AffiliationID; newActionBy.IsActionLead = actionByInPreviousVersion.IsActionLead; newActionBy.RoleDescription = actionByInPreviousVersion.RoleDescription; clonedNewActionBies.Add(newActionBy); } return clonedNewActionBies; } }
public Core.Action Map(ESDATModel esdatModel, ChemistryFileData chemistry) { var entity = Draft(esdatModel, chemistry); // Feature Actions var featureAction = _chemistryFactory.FeatureActionMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(entity, featureAction); // Sampling Feature var samplingFeature = _chemistryFactory.SamplingFeatureMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(featureAction, samplingFeature); // Result // Each Feature Action contains 1 Result (Chemistry) { var result = _chemistryFactory.ResultMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(featureAction, result); // Unit var unit = _chemistryFactory.UnitMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(result, unit); // Variable var variable = _chemistryFactory.VariableMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(result, variable); // Datasets Result { var datasetsResult = _chemistryFactory.DatasetsResultMapper.Map(esdatModel); ODM2EntityLinker.Link(result, datasetsResult); var dataset = _chemistryFactory.DatasetMapper.Map(esdatModel); ODM2EntityLinker.Link(datasetsResult, dataset); } // Processing Level var processingLevel = _chemistryFactory.ProcessingLevelMapper.Map(esdatModel); ODM2EntityLinker.Link(result, processingLevel); // Measurement Result { var measurementResult = _chemistryFactory.MeasurementResultMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(result, measurementResult); ODM2EntityLinker.Link(measurementResult, unit); var measurementResultValue = _chemistryFactory.MeasurementResultValueMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(measurementResult, measurementResultValue); } // Result Extension Property Values { var properties = new Dictionary <string, string>(); properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeySampleCode] = chemistry.SampleCode; properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyPrefix] = chemistry.Prefix; properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyTotalOrFiltered] = chemistry.TotalOrFiltered; properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyResultType] = chemistry.ResultType; properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQL] = chemistry.EQL.ToString(); properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQLUnits] = chemistry.EQLUnits; properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyComments] = chemistry.Comments; properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyUCL] = chemistry.UCL.ToString(); properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyLCL] = chemistry.LCL.ToString(); foreach (var property in properties) { var extensionProperty = _chemistryFactory.ExtensionPropertyMapper.Map(property.Key); var propertyID = extensionProperty.PropertyID; var propertyValue = property.Value; var resultExtensionPropertyValue = _chemistryFactory.ResultExtensionPropertyValueMapper.Map(propertyID, propertyValue); ODM2EntityLinker.Link(result, resultExtensionPropertyValue); } } } // Action Bies { ActionBy actionBy = _chemistryFactory.ActionByMapper.Map(esdatModel); ODM2EntityLinker.Link(entity, actionBy); var person = _chemistryFactory.PersonMapper.Map(esdatModel); _chemistryFactory.AffiliationMapper.Person = person; var affiliation = _chemistryFactory.AffiliationMapper.Map(esdatModel); ODM2EntityLinker.Link(actionBy, affiliation); } // Method { var method = _chemistryFactory.MethodMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(entity, method); _chemistryFactory.OrganizationMapper.SampleFileData = SampleFileData; var organization = _chemistryFactory.OrganizationMapper.Map(esdatModel, chemistry); ODM2EntityLinker.Link(method, organization); } // Related Actions _chemistryFactory.RelatedActionMapper.SetRelationship(entity, _WQDefaultValueProvider.ActionRelationshipTypeCVChemistry, ParentAction); RelatedAction relatedAction = _chemistryFactory.RelatedActionMapper.Map(esdatModel); ODM2EntityLinker.Link(entity, relatedAction); return(entity); }
public ActionResult CreatePost(CreatePostModel model) { if (ModelState.IsValid) { int textbookId = model.TextBookId; // if we have a new textbook, store it if (model.IsNewBook) { // proceed if course id exists; otherwise create the course first Course course = CourseHandler.getCourseByName(model.CourseName); if (course == null) { model.CourseId = CourseHandler.CreateCourse(model.CourseName); } var newTextbook = new Textbook( -1, // id doesnt matter here model.BookTitle, model.ISBN, model.Author, model.CourseId, model.CourseName, model.BookImageUrl, null, 1, 0, DateTime.Now, DateTime.Now ); textbookId = TextbookHandler.createTextBook(newTextbook); } int profileId = ProfileHandler.GetProfileId(User.Identity.Name); int price = model.Price; ActionBy actionBy = model.ActionBy; if (model.IsNegotiable) { if (actionBy == ActionBy.Buyer) { price = int.MaxValue; } else { price = 0; } } var newPost = new Post( -1, // id doesnt matter here profileId, textbookId, actionBy, price, model.BookCondition, 0, 1, 0, DateTime.Now, DateTime.Now ); int postId = PostHandler.createPost(newPost); newPost.PostId = postId; Task.Run(() => QueueWorker.AddPost(newPost)); // TODO: redirect to special "you've successfully created post" page // with links to create another buy/sell post return(RedirectToAction("Index", "Home")); } // If we got this far, something failed, redisplay form IEnumerable <Textbook> textBookCollection = TextbookHandler.getAllTextbooks(); // test data //for(int i = 0; i < 100; i++) { // Textbook book = new Textbook( // i, // "Financial Accounting " + i, // "100000000000" + i, // "Author " + i, // 100 + i, // "AFM 10" + i, // null, // 10 + i, // 1, // 0, // DateTime.Now, // DateTime.Now // ); // textBookCollection.Add(book); //} model.PostTypes = SelectListUtility.getPostTypes(); model.BookConditions = SelectListUtility.getBookConditions(); model.Textbooks = textBookCollection; return(View("CreatePost", model)); }