private SampleUIModel Map(SampleDataModel dataModel) { return(new SampleUIModel { Description = dataModel.Description }); }
public JsonResult Audit(int id) { SampleDataModel SD = new SampleDataModel(); var AuditTrail = SD.GetAudit(id); return(Json(AuditTrail, JsonRequestBehavior.AllowGet)); }
public ActionResult Create() { SampleDataModel SD = new SampleDataModel(); SD.ID = -1; // indicates record not yet saved SD.DateOfBirth = DateTime.Now.AddYears(-25); return(View("Edit", SD)); }
public static SampleDataModel getData(string id) { string data = Singleton.Instance.get(); List <SampleDataModel> allData = JsonConvert.DeserializeObject <List <SampleDataModel> >(data); SampleDataModel model = allData.AsEnumerable().Where(a => a.Id == id).FirstOrDefault(); return(model); }
void Awake() { instance = this; SampleDataEntity sde = new SampleDataEntity(); this.DataEntity = sde; Watch(this); }
public static void save(SampleDataModel model) { string data = Singleton.Instance.get(); List <SampleDataModel> allData = JsonConvert.DeserializeObject <List <SampleDataModel> >(data); allData.Add(model); string newData = JsonConvert.SerializeObject(allData); Singleton.Instance.save(newData); }
public static void update(SampleDataModel model) { string data = Singleton.Instance.get(); List <SampleDataModel> allData = JsonConvert.DeserializeObject <List <SampleDataModel> >(data); SampleDataModel dbModel = allData.AsEnumerable().Where(a => a.Id == model.Id).FirstOrDefault(); dbModel = model; string newData = JsonConvert.SerializeObject(allData); Singleton.Instance.save(newData); }
// POST: api/EQ public HttpResponseMessage Post([FromBody] SampleDataModel model) { try { SampleRepository.save(model); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
// PUT api/values/5 public void Put(string id, [FromBody] SampleDataModel value) { var query = (from c in SampleData.AsEnumerable().Where(p => p._Id == id) select c).FirstOrDefault(); query._ApplicationId = value._ApplicationId; query._Amount = value._Amount; query._ClearedDate = value._ClearedDate; query._IsCleared = value._IsCleared; query._PostingDate = value._PostingDate; query._Summary = value._Summary; query._Type = value._Type; }
public ActionResult Edit(string id, SampleDataModel model) { try { // TODO: Add update logic here SampleRepository.update(model); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(string id, SampleDataModel collection) { try { v.Delete(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public void TestGetOne() { var sampleDataModel = new SampleDataModel().Get(new QueryModel() { Parameters = new Dictionary <string, object>() { { "IntData2", 1 }, }, }).First(); Debug.WriteLine(sampleDataModel.ToString()); Assert.IsNotNull(sampleDataModel); }
public async Task <IActionResult> InstallSampleData(SampleDataModel sampleData) { var fileBytes = await sampleData.MediaFile.GetBytesAsync(); //install the package var success = _installationService.InstallSamplePackage(fileBytes); if (success) { return(R.Success.Result); } return(R.Fail.With("error", T("Failed to install the sample package")).Result); }
public ActionResult Create(SampleDataModel model) { try { // TODO: Add insert logic here SampleRepository.save(model); return(RedirectToAction("Index")); } catch { return(View()); } }
public SampleDataModel ReadSample() { var memoryUsed = GetMemoryUsage(); var model = new SampleDataModel(SampleTypeId) { Value = memoryUsed, StringValue = string.Format("{0:0.00} Byte(s)", memoryUsed), TimeStamp = DateTime.UtcNow, Description = this.Description }; return(model); }
public ActionResult Save(SampleDataModel Rec) { SampleDataModel SD = new SampleDataModel(); if (Rec.ID == -1) { SD.CreateRecord(Rec); } else { SD.UpdateRecord(Rec); } return(Redirect("/")); }
public ActionResult Create(SampleDataModel model) { try { v.Post(model); // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public SampleDataModel ReadSample() { var cpuUsage = GetCpuUsage(); var model = new SampleDataModel(SampleTypeId) { Value = cpuUsage, StringValue = string.Format("{0:0.00} %", cpuUsage), TimeStamp = DateTime.UtcNow, Description = this.Description }; return(model); }
public ActionResult Edit(string id, SampleDataModel collection) { try { // TODO: Add update logic here var model = v.Get(id); model._Amount = collection._Amount; model._ApplicationId = collection._ApplicationId; model._ClearedDate = collection._ClearedDate; model._IsCleared = collection._IsCleared; model._PostingDate = collection._PostingDate; model._Summary = collection._Summary; model._Type = collection._Type; v.Put(id, model); return(RedirectToAction("Index")); } catch { return(View()); } }
private static void Main(string[] args) { var dbContext = new SampleDataModel(); //EXAMPLE 1: use sql scalar user defined function in projection var userProfiles = dbContext.Users.Select(x => new { EmailAddress = x.EmailAddress, FullName = UserDbFunction.FnUserFullName(x.Userid) }).Take(3).ToList(); Console.WriteLine("Top 3 users:"); foreach (var userProfile in userProfiles) { Console.WriteLine($"Email Address: {userProfile.EmailAddress} - Full Name: {userProfile.FullName}"); } //EXAMPLE 2: use sql scalar user defined function in restriction (where clause) //Find 'Barbara Santa' email address var user = dbContext.Users.FirstOrDefault(x => UserDbFunction.FnUserFullName(x.Userid).Equals("Barbara Santa", StringComparison.OrdinalIgnoreCase)); Console.WriteLine(Environment.NewLine + $"'Barbara Santa' email address: {user?.EmailAddress}"); Console.ReadLine(); }
public void BasicSorting() { List <SampleDataModel> results = null; string filter = null;// "Page";// null;// "DESC"; try { foreach (var sortingTestList in UnitTestHelpers.SortingTestList) { if (filter != null && filter.Length > 0) { // we can filter lists while debugging if (!sortingTestList.Key.ToUpper().Contains(filter.ToUpper())) { Debug.WriteLine("\nSkipping scenario " + sortingTestList.Key); continue; } } Debug.WriteLine("Testing scenario " + sortingTestList.Key); var testingData = sortingTestList.Value as BasicSortingPagingTestData; results = new SampleDataModel().Get(testingData.QueryToUse); foreach (SampleDataModel resultData in results) { // TODO: Fix ObjectEquals operator override bool areEqual = (resultData == testingData.ExpectedSortedDataModelResult.Dequeue()); Assert.IsTrue(areEqual); if (!areEqual) { Debugger.Break(); } } } } catch (Exception e) { Debug.WriteLine(e.Message); Debugger.Break(); } }
public void Pass() { // Arrange int zero = 0; int one = 1; int two = 2; // Act SampleDataModel firstDataModel = new SampleDataModel (0); SampleDataModel secondDataModel = new SampleDataModel (1); SampleDataModel thirdDataModel = new SampleDataModel (2); ObservableCollection<SampleDataModel> dataCollection = new ObservableCollection<SampleDataModel> (); dataCollection.Add (firstDataModel); dataCollection.Add (secondDataModel); dataCollection.Add (thirdDataModel); // Assert Assert.AreEqual (zero, dataCollection.IndexOf (firstDataModel)); Assert.AreEqual (one, dataCollection.IndexOf (secondDataModel)); Assert.AreEqual (two, dataCollection.IndexOf (thirdDataModel)); }
private List <SampleDataModel> LoadMockSampleData() { var mockList = new List <SampleDataModel>(); var cpu1 = new SampleDataModel(1) { StringValue = "15.23 %", Value = 15.23, TimeStamp = DateTime.UtcNow.AddMinutes(-1) }; var cpu2 = new SampleDataModel(1) { StringValue = "35.98 %", Value = 35.98, TimeStamp = DateTime.UtcNow.AddSeconds(-20) }; var memeory1 = new SampleDataModel(2) { StringValue = "555998.235 Byte(s)", Value = 555998.235, TimeStamp = DateTime.UtcNow.AddSeconds(-10) }; var memeory2 = new SampleDataModel(2) { StringValue = "23598.2489 Byte(s)", Value = 23598.2489, TimeStamp = DateTime.UtcNow }; mockList.Add(cpu1); mockList.Add(cpu2); mockList.Add(memeory1); mockList.Add(memeory2); return(mockList); }
public void Fail() { // Arrange int zero = 0; int one = 1; int two = 2; // Act var firstDataModel = new SampleDataModel(0); var secondDataModel = new SampleDataModel(1); var thirdDataModel = new SampleDataModel(2); var dataCollection = new ObservableCollection <SampleDataModel> (); dataCollection.Add(firstDataModel); dataCollection.Add(secondDataModel); dataCollection.Add(thirdDataModel); // Assert Assert.AreEqual(two, dataCollection.IndexOf(firstDataModel)); Assert.AreEqual(zero, dataCollection.IndexOf(secondDataModel)); Assert.AreEqual(one, dataCollection.IndexOf(thirdDataModel)); }
// POST api/values public void Post([FromBody] SampleDataModel value) { SampleData.Add(value); }
public void OneBigTest() { SampleDataModel sampleDataModel2; SampleDataModel sampleDataModel3; SampleDataModel sampleDataModel = new SampleDataModel() { TextData1 = "my new TextData", IntData2 = 3, CustomEnum = MyCustomEnum.Foo, }; // I haven't yet added fetching the key back, but that is a simple modification // so let's get it by TextData1 then by IntData2 sampleDataModel.Upsert(); // pass in name value pairs of the columns and search values (using new instance for testing convenience) // use TextData1 sampleDataModel2 = SampleDataModel.Get(new Dictionary <string, object>() { { "TextData1", "my new TextData" }, }); Debug.WriteLine(sampleDataModel2.ToString()); Assert.IsNotNull(sampleDataModel2); // use int sampleDataModel3 = SampleDataModel.Get(new Dictionary <string, object>() { { "IntData2", 3 }, }); Debug.WriteLine(sampleDataModel3.ToString()); Assert.IsNotNull(sampleDataModel3); // change a value sampleDataModel2.IntData2 = 10; sampleDataModel2.Upsert(); // fetch back into #3 by id to see if it changed sampleDataModel3 = SampleDataModel.Get(new Dictionary <string, object>() { { "Id", sampleDataModel2.Id } }); Debug.WriteLine(sampleDataModel3.ToString()); Assert.AreEqual(sampleDataModel3.IntData2, sampleDataModel2.IntData2); // add a few (haven't handled bulk add yet but that's easy too. So for now, one at a time sampleDataModel = new SampleDataModel() { TextData1 = "my new TextData2", IntData2 = 55, CustomEnum = MyCustomEnum.Foo, }; sampleDataModel.Upsert(); sampleDataModel = new SampleDataModel() { TextData1 = "my new TextData3", IntData2 = 55, CustomEnum = MyCustomEnum.Foo, }; sampleDataModel.Upsert(); // now let's get them all // ISSUE: I have a byref issue in my List<T> List <SampleDataModel> result = SampleDataModel.GetList(); foreach (var sample in result) { Debug.WriteLine(sample.ToString()); } // now lets just get the ones with intData = 3 result = SampleDataModel.GetList(new Dictionary <string, object>() { { "IntData2", 55 } }); foreach (var sample in result) { Debug.WriteLine(sample.ToString()); } }
public void AddGetUpdateInsert() { //SampleDataModel sampleDataModel2; SampleDataModel sampleDataModel3; SampleDataModel sampleDataModel = new SampleDataModel() { TextData1 = "my new TextData", IntData2 = 3, CustomEnum = MyCustomEnum.Foo, }; /// /// /// TODO: Upsert Disabled /// /// // so let's get it by TextData1 then by IntData2 // sampleDataModel.Upsert<SampleDataModel>(); // pass in name value pairs of the columns and search values (using new instance for testing convenience) // use TextData1 //sampleDataModel2 = SampleDataModel.Get(new QueryModel() //{ // Parameters = new Dictionary<string, object>() // { // { "TextData1", "my new TextData" }, // }, //}); //Debug.WriteLine(sampleDataModel2.ToString()); //Assert.IsNotNull(sampleDataModel2); // use int sampleDataModel3 = new SampleDataModel().Get(new QueryModel() { Parameters = new Dictionary <string, object>() { { "IntData2", 1 }, }, }).First(); Debug.WriteLine(sampleDataModel3.ToString()); Assert.IsNotNull(sampleDataModel3); // Disabling Upsert for now // change a value //sampleDataModel2.IntData2 = 10; //sampleDataModel2.Upsert<SampleDataModel>(); //// fetch back into #3 by id to see if it changed //sampleDataModel3 = SampleDataModel.Get(new QueryModel() //{ // Parameters = new Dictionary<string, object>() //{ // { "Id", sampleDataModel2.Id } //}, //}); //Debug.WriteLine(sampleDataModel3.ToString()); //Assert.AreEqual(sampleDataModel3.IntData2, sampleDataModel2.IntData2); //// add a few (haven't handled bulk add yet but that's easy too. So for now, one at a time //sampleDataModel = new SampleDataModel() //{ // TextData1 = "my new TextData2", // IntData2 = 55, // CustomEnum = MyCustomEnum.Foo, //}; //sampleDataModel.Upsert<SampleDataModel>(); //sampleDataModel = new SampleDataModel() //{ // TextData1 = "my new TextData3", // IntData2 = 55, // CustomEnum = MyCustomEnum.Foo, //}; //sampleDataModel.Upsert<SampleDataModel>(); //// now let's get them all //List<SampleDataModel> result = SampleDataModel.GetList(); //foreach (var sample in result) // Debug.WriteLine(sample.ToString()); //// now lets just get the ones with intData = 3 //result = SampleDataModel.GetList(new QueryModel() //{ // Parameters = new Dictionary<string, object>() // { // {"IntData2",55} // }, //}); //foreach (var sample in result) // Debug.WriteLine(sample.ToString()); }
public ActionResult Edit(int id) { SampleDataModel SD = new SampleDataModel(); return(View(SD.GetData(id))); }
public ActionResult Index(bool ShowDeleted = false) { SampleDataModel SD = new SampleDataModel(); return(View(SD.GetAllData(ShowDeleted))); }
public void Delete(int id) { SampleDataModel SD = new SampleDataModel(); SD.DeleteRecord(id); }
public IActionResult SaveData(SampleDataModel model) { return(PartialView(model)); }