public void EditCategory(SpentCategory request) { if (request.Id.ToGuid() == Guid.Empty) { try { if (!string.IsNullOrWhiteSpace(request.Pattern)) { // ReSharper disable once ReturnValueOfPureMethodIsNotUsed new Regex(request.Pattern, RegexOptions.None, TimeSpan.FromSeconds(0.1)).Match("test"); } } catch { request.Pattern = ""; } var spentCategoryModel = new SpentCategoryModel(request.Pattern, request.Category, request.Kind); ObjectRepository.Add(spentCategoryModel); } else { var id = request.Id.ToGuid(); var categoryObj = ObjectRepository.Set <SpentCategoryModel>().First(v => v.Id == id); categoryObj.Pattern = request.Pattern; categoryObj.Category = request.Category; categoryObj.Kind = request.Kind; } }
private SpentCategory ToSpentCategory(SpentCategoryModel spentCategoryModel) { return(new SpentCategory { Category = spentCategoryModel.Category ?? "", Id = spentCategoryModel.Id.ToUUID(), Kind = spentCategoryModel.Kind, Pattern = spentCategoryModel.Pattern ?? "" }); }
public SpentCategoryJsModel(SpentCategoryModel model) { _model = model; }