public async Task <ActionResult <Sample> > PostAsync([FromBody] SampleInput input) { var id = await repository.InsertAsync(new SampleTable { IndexedColumn = DateTime.Now, CustomTypeColumn = input.Text }, CancellationToken.None); return(Adapt(await repository.GetAsync(id, CancellationToken.None))); }
public ActionResult Save(SampleInput model) { if (ModelState.IsValid) { } return(View(model)); }
public FormDataValidationResult Validate() { var result = new FormDataValidationResult(); if (Title.IsNullOrWhiteSpace()) { result.AddErrorMessage("Title is required"); } if (Description.IsNullOrWhiteSpace()) { result.AddErrorMessage("Description is required"); } if (Constraints.IsNullOrWhiteSpace()) { result.AddErrorMessage("Constraints is required"); } if (InputSpecification.IsNullOrWhiteSpace()) { result.AddErrorMessage("InputSpecification is required"); } if (OutputSpecification.IsNullOrWhiteSpace()) { result.AddErrorMessage("OutputSpecification is required"); } if (SampleInput.IsNullOrWhiteSpace()) { result.AddErrorMessage("SampleInput is required"); } if (SampleOutput.IsNullOrWhiteSpace()) { result.AddErrorMessage("SampleOutput is required"); } if (Notes.IsNullOrWhiteSpace()) { result.AddErrorMessage("Notes is required"); } if (TimeLimit == 0 || TimeLimit > 20) { result.AddErrorMessage("TimeLimit is invalid"); } if (MemoryLimit == 0 || MemoryLimit > 512) { result.AddErrorMessage("MemoryLimit is invalid"); } if (string.IsNullOrEmpty(TestCaseInput)) { result.AddErrorMessage("TestCaseInput is required"); } if (string.IsNullOrEmpty(TestCaseOutput)) { result.AddErrorMessage("TestCaseOutput is required"); } return(result); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var vals = (ObservableCollection <Pair <string, string> >)value; List <SampleInput> result = new List <SampleInput>(); foreach (var val in vals) { var v = (Pair <string, string>)val; if (!v.A.StartsWith(VARIABLEPREFIX)) { continue; } var state = ServiceLocator.Current.GetInstance <MainViewModel>().Model; if (state == null) { break; } SampleInput input = new SampleInput() { Key = v.A, Title = "[VAR] " + v.A, Number = -2, Elements = new System.Collections.ObjectModel.ObservableCollection <InputBase>() }; var baseInput = state.Inputs.Where(x => { int inumber = -1; return(x.Key == v.B || x.Title == v.B || (int.TryParse(v.B, out inumber) && x.Number == inumber)); }).FirstOrDefault(); if (baseInput != null) { foreach (var item in baseInput.Elements) { var element = ((InputBase)item.GetType().GetConstructor(new Type[] { }).Invoke(new object[] { })); element.Name = item.Name; element.Index = item.Index; input.Elements.Add(element); } } result.Add(input); } return(result); }
private static void ProcessPayment(int options) { int memberShipType = 0; var paymentType = (PaymentType)Enum.Parse(typeof(PaymentType), options.ToString()); if (options == 3 || options == 6) { paymentType = (PaymentType)Enum.Parse(typeof(PaymentType), "3".ToString()); memberShipType = options == 3 ? 1 : 2; var result = ProcessOrders.GetPaymentMethod(paymentType); var sampleInput = SampleInput.GetSampleDataMember(memberShipType); if (result != null) { var data = result.ProcessPayment(sampleInput); Console.WriteLine($"Order of {paymentType.ToString()} and {data.Message}\n"); } else { Console.WriteLine("Invalid operation"); } } else { IProcessOrder processor = ProcessOrders.GetPaymentMethod(paymentType); var data = SampleInput.GetSampleDataForOrder(paymentType); if (processor != null) { var result = processor.ProcessPayment(data); Console.WriteLine($"Order of {paymentType.ToString()} and {result.Message}\n"); } else { Console.WriteLine("Invalid operation"); } } }
public SampleOutput Get(SampleInput input) { return new SampleOutput(); }
public SampleOutput Get(SampleInput input) { return(new SampleOutput()); }