protected override void ParseItemNameAndQuantity(DraftItem draftItem) { const string gil = @"ギル"; const char currencyIndicator = '×'; string quantityStr; if (draftItem.RawItemName.EndsWith(gil)) { quantityStr = draftItem.RawItemName.Replace(gil, string.Empty); } else { var match = Context.ItemQuantityRegex.Match(draftItem.RawItemName); quantityStr = match.Groups["Quantity"].Value; } try { draftItem.Quantity = int.Parse(quantityStr.Replace(Context.NumberDelimiterLocalized, string.Empty)); draftItem.ItemName = draftItem.RawItemName.Replace(quantityStr, string.Empty); if (draftItem.ItemName[draftItem.ItemName.Length - 1] == currencyIndicator) { draftItem.ItemName = draftItem.ItemName.Remove(draftItem.ItemName.Length - 1); } } catch { draftItem.Quantity = 1; draftItem.ItemName = draftItem.RawItemName; } }
protected Item CreateItem(Match rawItemMatch) { var draftItem = new DraftItem(); ParseRawItemName(rawItemMatch, draftItem); ParseItemNameAndQuantity(draftItem); return(CreateItemFromDraft(draftItem)); }
public IActionResult AddDraftItem(DraftItem DraftItem) { if (ModelState.IsValid) { var postResult = Helper.PostValueToSevice <DraftItem>("POST", DraftItem); return(Json(new { success = postResult.result, message = postResult.message })); } return(Json(new { success = false, message = "Model Is Not Vald!" })); }
public static Rest.Item ToRest(this DraftItem source) { return(source == null ? null : new Rest.Item(source) { Classification = source.Classification.ToRest(), AdditionalClassifications = source.AdditionalClassifications?.Select(x => x.ToRest()).ToArray(), RelatedLot = source.Lot?.StringId }.DropComplexProperties()); }
protected Item CreateItemFromDraft(DraftItem draftItem) { var item = FindItem(draftItem.ItemName, draftItem.Quantity); if (item == null) { return(null); } item.Quantity = draftItem.Quantity; item.IsHQ = IsHQ(); return(item); }
public IActionResult EditDraftItem(long id, DraftItem DraftItem) { if (ModelState.IsValid) { DraftItem.State = BusinessEntity.Models.Base.Enums.ObjectState.Active; var postResult = Helper.PostValueToSevice <DraftItem>("PUT?id=" + DraftItem.Id.ToString(), DraftItem); return(Json(new { success = postResult.result, message = postResult.message })); } return(Json(new { success = false, message = "Model Is Not Valid!" })); }
protected virtual void ParseItemNameAndQuantity(DraftItem draftItem) { var match = Context.ItemNameRegex.Match(draftItem.RawItemName); draftItem.ItemName = match.Groups["ItemName"].Value.Trim(); var quantityStr = match.Groups["Quantity"].Value.Replace(Context.NumberDelimiterLocalized, string.Empty); try { draftItem.Quantity = int.Parse(quantityStr); } catch { draftItem.Quantity = 1; } }
protected void ParseRawItemName(Match match, DraftItem draftItem) { var rawItemName = match.Groups["RawItemName"].Value; foreach (var hqChar in Context.HQChars) { rawItemName = rawItemName.Replace(" " + hqChar, string.Empty); rawItemName = rawItemName.Replace(hqChar, string.Empty); } draftItem.RawItemName = rawItemName; draftItem.RawItemName = draftItem.RawItemName.Replace("No# ", "No. "); foreach (var leadingArticle in Context.LeadingArticles) { draftItem.RawItemName = draftItem.RawItemName.Replace(leadingArticle, string.Empty); } }
public static ItemDTO ToDTO(this DraftItem source) { return(source == null ? null : new ItemDTO(source) { TenderGuid = source.Tender.Guid, LotStringId = source.Lot?.StringId, Classification = source.Classification.ToDTO(), AdditionalClassifications = source.AdditionalClassifications?.Select(x => x.ToDTO()).ToList(), Features = source.Tender.Features? .Where(m => m.FeatureType == FeatureType.Item && m.RelatedItem == source.StringId) .Select(m => m.ToDTO()) .ToList(), //Documents = source.Tender.Documents? // .Where(m => m.DocumentOf == RelatedTo.Item && m.RelatedId == source.StringId) // .Select(x => x.ToDTO()) // .ToList() }); }
public IActionResult DeleteDraftItem(DraftItem DraftItem) { var postResult = Helper.PostValueToSevice <DraftItem>("Delete?id=" + DraftItem.Id.ToString(), DraftItem); return(Json(new { success = postResult.result, message = postResult.message })); }