static void Main(string[] args) { GeneralModel generalModel = new GeneralModel(); generalModel.RoverModel = new List <RoverModel>(); generalModel.SizeRectangle = new int[] { Convert.ToInt32(data1.Split(" ")[0]), Convert.ToInt32(data1.Split(" ")[1]) }; generalModel.RoverModel.Add(new RoverModel { StartPoint = new string[] { data2.Split(" ")[0], data2.Split(" ")[1], data2.Split(" ")[2] }, Direction = data3 }); generalModel.RoverModel.Add(new RoverModel { StartPoint = new string[] { data4.Split(" ")[0], data4.Split(" ")[1], data4.Split(" ")[2] }, Direction = data5 }); List <string> response = Run(generalModel); for (int i = 0; i < response.Count; i++) { Console.WriteLine(response[i]); } }
/// <summary> /// GetProfileDetails gets the users [account number,hourly charge, bank name, account name, working hours] /// </summary> /// <returns> /// Dictionary<String,String> holding the data with keys [AccountNumber, Charge, BankName, AccountName, WorkingHours] /// </returns> public static async Task <Dictionary <String, String> > GetProfileDetails() { Dictionary <String, String> ResultData = new Dictionary <String, String>(); try { String ResultJson = await GeneralModel.GetAsync("user/profile/medic/" + Utilities.MedicID); var DecodedJson = JObject.Parse(ResultJson); if ((bool)DecodedJson["status"]) { var info = DecodedJson["info"]; ResultData.Add("AccountNumber", info["account_number"].ToString()); ResultData.Add("Charge", info["hourly_charge"].ToString()); ResultData.Add("BankName", info["bank_name"].ToString()); ResultData.Add("AccountName", info["account_name"].ToString()); ResultData.Add("WorkingHours", info["working_hours"].ToString()); } else { await App.Current.MainPage.DisplayAlert("Alert", "Unknown Medic ID", "Ok"); } } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "Ok"); } return(ResultData); }
public static async Task <bool> PostSettings(bool ChangePassword, String Phone = "", String OldPassword = "", String NewPassword = "") { Dictionary <int, String[]> Data = new Dictionary <int, string[]> { { 0, new String[] { "user_id", Utilities.ID.ToString() } }, }; if (!ChangePassword) { Data.Add(1, new String[] { "phone", Phone }); } else { Data.Add(1, new String[] { "change_password", "1" }); Data.Add(2, new String[] { "old_password", OldPassword }); Data.Add(3, new String[] { "new_password", NewPassword }); } try { String ResultJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), "user/profile/settings/" + Utilities.ID); var DecodedJson = JObject.Parse(ResultJson); return((bool)DecodedJson["status"]); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "Ok"); return(false); } }
public static void LoadMainFunctions() { string jsonString = File.ReadAllText(Alt.Server.Resource.Path + "/settings/main.json"); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("------------------------------------------------------------------------"); Console.WriteLine("-------- VenoX Global Systems is starting... --------"); Console.WriteLine("-------- " + Constants.VNXGLOBALSYSTEMSVERSION + " --------"); Console.WriteLine("-------- Loading Config File.... --------"); Console.WriteLine("---------------------------------------------"); // GeneralModel = JsonSerializer.Deserialize <GeneralModel>(jsonString); // Console.ResetColor(); if (GeneralModel.AnticheatSystemActive) { Core.Debug.OutputLog("-------- [Settings] : Anticheat Active! --------", ConsoleColor.Green); LoadAnticheatConfig(); } else { Core.Debug.OutputLog("-------- [Settings] : Anticheat Inactive! --------", ConsoleColor.Red); } if (GeneralModel.GlobalBanSystemActive) { Core.Debug.OutputLog("-------- [Settings] : Global-Ban-System Active! --------", ConsoleColor.Green); } else { Core.Debug.OutputLog("-------- [Settings] : Global-Ban-System not Active! --------", ConsoleColor.Red); } Core.Debug.OutputLog("-------- [VenoX Global Systems started] --------", ConsoleColor.DarkGreen); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine("------------------------------------------------------------------------"); Console.ResetColor(); }
public static async Task <bool> PostReview(String Review, int Stars, int MedicID, String Title) { //user/rate?medic_id=&user_id= Dictionary <int, String[]> Data = new Dictionary <int, string[]> { { 0, new String[] { "user_id", Utilities.ID.ToString() } }, { 1, new String[] { "medic_id", MedicID.ToString() } }, { 2, new String[] { "review", "{Title [length=" + Title.Length + "]:" + Title + "}{Content [length=" + Review.Length + "]:" + Review + "}" } }, { 3, new String[] { "rate", Stars.ToString() } }, }; try { String ResultJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), "user/rate"); var DecodedJson = JObject.Parse(ResultJson); return((bool)DecodedJson["status"]); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "Ok"); return(false); } }
public int Update(GeneralModel model) { try { var modelUpdate = new General() { id = model.id, name = model.name, group = model.group, status = model.status }; contextDB.Entry(modelUpdate).State = Microsoft.EntityFrameworkCore.EntityState.Modified; contextDB.SaveChanges(); return(modelUpdate.id); } catch (System.Exception ex) { throw ex; } }
static List <string> Run(GeneralModel generalModel) { List <string> result = new List <string>(); for (int x = 0; x < generalModel.RoverModel.Count; x++) { int[] point = { Convert.ToInt32(generalModel.RoverModel[x].StartPoint[0]), Convert.ToInt32(generalModel.RoverModel[x].StartPoint[1]) }; string lastDirection = generalModel.RoverModel[x].StartPoint[2]; foreach (var item2 in generalModel.RoverModel[x].Direction.ToCharArray()) { if (item2.ToString() == "L" || item2.ToString() == "R") { lastDirection = DirectionChange(lastDirection, item2.ToString()); } else if (item2.ToString() == "M") { Step step = steps.Where(x => x.Direction == lastDirection).FirstOrDefault(); point[0] = point[0] + step.X; point[1] = point[1] + step.Y; if (point[0] > generalModel.SizeRectangle[0] || point[1] > generalModel.SizeRectangle[1]) { Console.Write("The robot went out of the drawn area."); } } } result.Add(point[0].ToString() + " " + point[1].ToString() + " " + lastDirection); } return(result); }
public JsonResult SavePaymentRecord(IList <OrderNow> values) { if (values != null) { decimal amount = GeneralModel.GetTotalAmount(values); var response = ChargeCreditCard.Run(amount); if (response.refId != null) { Order newOrder = new Order(); newOrder.userId = Convert.ToInt32(Session["UserId"].ToString()); newOrder.dateTime = DateTime.Now.ToString("HH:mm tt dd/MM/yyyy"); newOrder.status = "Pending"; newOrder.totalPrice = amount.ToString(); newOrder.transId = response.refId; using (FoodOrderDbContext db = new FoodOrderDbContext()) { db.Orders.Add(newOrder); db.SaveChanges(); } foreach (var item in values) { decimal itemid = GeneralModel.GetItemID(item.Name); decimal orderId = GeneralModel.GetOrderId(); decimal quantity = item.count; GeneralModel.SavetoItemDetials(itemid, orderId, quantity); GeneralModel.UpdateQuantity(itemid, quantity); } } return(Json(new { result = 1 }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = 0 }, JsonRequestBehavior.AllowGet)); }
public async void LoadViaje() { LoginModel = new LoginDataBase(); viajesModel = new ViajesDataBase(); viajes = new ViajesModel(); intermedios = new IntermediosModel(); intermediosModel = new IntermediosDataBase(); var usua = LoginModel.GetMembers(); foreach (var item in usua) { this.idusuario = item.id; } var loginPOS = new GeneralModel { id = idusuario, }; var url = Application.Current.Resources["UrlAPI"].ToString(); var prefix = Application.Current.Resources["UrlPrefix"].ToString(); var controller = Application.Current.Resources["UrlViajes"].ToString(); var response = await this.apiService.Post <GeneralModel>(url, prefix, controller, loginPOS); if (!response.IsSuccess) { await App.Current.MainPage.DisplayAlert("Error", "Este usuario aun no tiene viajes asignados", "Aceptar"); return; } this.MyViajes = (List <GeneralModel>)response.Result; if (MyViajes != null) { viajesModel.DeleteTable(); } //Agregar a la tabla de viajes foreach (var item in MyViajes) { viajes.id = item.id; viajes.nombre = item.nombre + " " + item.horaViaje; viajes.idOrigen = item.idOrigen; viajes.idDestino = item.idDestino; viajes.origen = item.origen; viajes.destino = item.destino; viajes.valor = item.valor; viajes.Hora = item.horaViaje; viajes.Bus = item.Bus; viajes.Placa = item.Placa; viajesModel.AddMember(viajes); } this.Viajespick = new ObservableCollection <ViajesModel>(viajesModel.GetMembers().OrderBy(x => x.nombre)); }
public async Task <IActionResult> PutGeneralModel([FromRoute] int id, [FromBody] GeneralModel generalModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != generalModel.ID) { return(BadRequest()); } _context.Entry(generalModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GeneralModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static async Task <Dictionary <String, String> > GetSettings(int ID) { Dictionary <String, String> MyData = new Dictionary <string, string>(); String ResultJson = await GeneralModel.GetAsync("user/profile/settings/" + ID); var DecodedJson = JObject.Parse(ResultJson); MyData.Add("name", DecodedJson["info"]["name"].ToString()); MyData.Add("email", DecodedJson["info"]["email"].ToString()); MyData.Add("phone", DecodedJson["info"]["phone"].ToString()); MyData.Add("dob", DecodedJson["info"]["date_of_birth"].ToString()); MyData.Add("gender", DecodedJson["info"]["gender"].ToString()); MyData.Add("BloodGroup", DecodedJson["info"]["blood_group"].ToString()); MyData.Add("address", DecodedJson["info"]["address"].ToString()); MyData.Add("IsMedic", DecodedJson["info"]["is_medic"].ToString()); if ((bool)DecodedJson["info"]["is_medic"]) { MyData.Add("MedicCategory", DecodedJson["info"]["category"].ToString()); MyData.Add("MedicId", DecodedJson["info"]["medic_id"].ToString()); } return(MyData); }
public static async Task <bool> BookAppointment(int UserID, String DateBooked, TimeSpan TimeBooked, MedicalPractitionerType AppointmentType, int MedPRactID, String Description, String PhoneNo) { String Time12Hours = "", Meridiem = ""; int hours = Convert.ToInt32(TimeBooked.ToString("hh")); if (hours > 12) { Time12Hours += (hours - 12); Meridiem += "PM"; } else if (hours == 0) { Time12Hours += "12"; Meridiem += "AM"; } else if (hours == 12) { Time12Hours += "12"; Meridiem += "PM"; } else { Time12Hours += hours; Meridiem += "AM"; } Time12Hours += ":" + TimeBooked.ToString("mm"); Time12Hours += " "; Time12Hours += Meridiem; Dictionary <int, String[]> Data = new Dictionary <int, string[]> { { 0, new String[] { "user_id", Utilities.ID.ToString() } }, { 1, new String[] { "entity_id", MedPRactID.ToString() } }, { 2, new String[] { "appointment_type", (AppointmentType == MedicalPractitionerType.Doctor) ? "p" : "i" } }, { 3, new String[] { "time", Time12Hours } }, { 4, new String[] { "phone_number", PhoneNo } }, { 5, new String[] { "description", Description } }, { 6, new String[] { "date", DateBooked } }, }; try { String ResponseJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), "user/appointments/new"); var DecodedJson = JObject.Parse(ResponseJson); if (!(bool)DecodedJson["status"]) { await App.Current.MainPage.DisplayAlert("Alert", DecodedJson["message"].ToString(), "ok"); } return(Convert.ToBoolean(DecodedJson["status"])); } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "ok"); return(false); } }
public static void ApplyToGeneral(General rule, GeneralModel command) { rule.RuleId = command.RuleId > 0 ? command.RuleId : rule.RuleId; rule.Description = command.Description; rule.InternalType = command.InternalType; rule.Type = command.Type; rule.Value = command.Value; }
public static TestModel ReadContentById(int id) { GeneralModel gm = new GeneralModel(); Report selected = gm.Reports.Find(id); string bytesAsString = Encoding.UTF8.GetString(selected.contenuto); return(JsonConvert.DeserializeObject <TestModel>(bytesAsString)); }
public static async Task <String> GetBioDetails(int MedicID) { String ResultJson = await GeneralModel.GetAsync("user/profile/bio/" + MedicID); var DecodedJson = JObject.Parse(ResultJson); return((DecodedJson["bio"].ToString() == String.Empty) ? "" : DecodedJson["bio"].ToString()); }
public static async Task <int> AppointmentStatus(int RequestStatus, int AppointmentID, int UserID) { String ResponseJson = ""; Dictionary <int, String[]> Data = new Dictionary <int, string[]> { { 0, new String[] { "id", AppointmentID.ToString() } }, { 1, new String[] { "status", RequestStatus.ToString() } }, }; if (RequestStatus == -1) { Data.Add(2, new String[] { "remark", "Appointment Rejected." }); } try { if (RequestStatus == 0) { await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), "user/appointments/"); return(0); } else { ResponseJson = await GeneralModel.PostAsync(Utilities.PostDataEncoder(Data), "user/appointments/"); var DecodedJson = JObject.Parse(ResponseJson); //status message if ((bool)DecodedJson["status"] && (int)DecodedJson["appointment_status"] == 1) { bool InitMessage = await ChatController.SendChat(UserID, "{Appointment Accepted, Default Message}"); if (InitMessage) { return(1); } return(0); } else if ((bool)DecodedJson["status"] && (int)DecodedJson["appointment_status"] != 1) { return((int)DecodedJson["appointment_status"]); } else { return(-2); } } } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Alert", ex.Message, "ok"); return(-1); } }
public int CreateGeneral(GeneralModel value) { generalRepository.Insert(new General { Id = value.Id, Description = value.Description, Name = value.Name }); return(generalRepository.Save()); }
private static General MapToGeneral(GeneralModel command) { return(new General() { Description = command.Description, InternalType = command.InternalType, RuleId = command.RuleId, Type = command.Type, Value = command.Value }); }
public int UpdateGeneral(int id, GeneralModel value) { generalRepository.Update(id, new General { Id = id, Description = value.Description, Name = value.Name }); return(generalRepository.Save()); }
public ActionResult Delete(int id, GeneralModel collection) { var tbGeneral = objContext.CONTRACTS_CONDITIONS_GENERAL.Where(x => x.Id == id).SingleOrDefault(); if (tbGeneral != null) { objContext.CONTRACTS_CONDITIONS_GENERAL.Remove(tbGeneral); objContext.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id, GeneralModel model) { GeneralModel tbGeneral = objContext.CONTRACTS_CONDITIONS_GENERAL.Where(x => x.Id == model.Id).SingleOrDefault(); if (tbGeneral != null) { objContext.Entry(tbGeneral).CurrentValues.SetValues(model); objContext.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbGeneral)); }
public static void SaveReportByEntity() { GeneralModel gm = new GeneralModel(); Report report = gm.Reports.Create(); report.stato = "prova"; report.data_download = DateTime.Now; report.data_upload = DateTime.Now; report.data_ultimo_salvataggio = DateTime.Now; gm.Reports.Add(report); gm.SaveChanges(); }
private void GoToRequestForm() { SearchResults searchResults = new SearchResults(WebDriver); searchResults = searchResults.Search("e-book"); GeneralModel page = searchResults.ChooseResultByIndex(Utils.GetRandomIndexes(1, searchResults.ResultCount)[0]); if (!page.PageContainsRequestForm()) { GoToRequestForm(); } _requestForm = page.GetRequestForm(); }
public async Task <IActionResult> PostGeneralModel([FromBody] GeneralModel generalModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Add(generalModel); db.Save(); //_context.General.Add(generalModel); //await _context.SaveChangesAsync(); return(CreatedAtAction("GetGeneralModel", new { id = generalModel.ID }, generalModel)); }
public ActionResult Create(GeneralModel model) { //try //{ // TODO: Add insert logic here objContext.CONTRACTS_CONDITIONS_GENERAL.Add(model); objContext.SaveChanges(); return(RedirectToAction("Index")); //} //catch //{ // return View(model); //} }
public JsonResult Create([FromBody] GeneralModel genralmodel) { Client cl = new Client(); Commande c = new Commande(); Client client = _context.Client.Find(genralmodel.ClientId); if (client == null) { cl.FullName = genralmodel.FullName; cl.Matricule = genralmodel.Matricule; cl.PhoneNumber = genralmodel.PhoneNumber; cl.Email = genralmodel.Email; _context.Client.Add(cl); _context.SaveChanges(); c.ClientId = cl.ClientId; c.Date = DateTime.Now; c.WithStamp = genralmodel.WithStamp; _context.Commande.Add(c); _context.SaveChanges(); genralmodel.Produits.ToList().ForEach(x => x.CommandeId = c.CommandeId); foreach (Produit produit in genralmodel.Produits) { _context.Produits.Add(produit); } _context.SaveChanges(); } else { c.ClientId = genralmodel.ClientId; c.Date = DateTime.Now; c.WithStamp = genralmodel.WithStamp; _context.Commande.Add(c); _context.SaveChanges(); genralmodel.Produits.ToList().ForEach(x => x.CommandeId = c.CommandeId); foreach (Produit produit in genralmodel.Produits) { _context.Produits.Add(produit); } _context.SaveChanges(); } int insertedRecords = _context.SaveChanges(); ViewBag.ClientId = new SelectList(_context.Client, "ClientId", "FullName", c.ClientId); return(Json(insertedRecords)); }
public static void SaveReportWith(string content) { GeneralModel gm = new GeneralModel(); Report report = gm.Reports.Create(); report.Id = new Random().Next(); report.stato = "prova"; report.contenuto = Encoding.ASCII.GetBytes(content); report.data_download = DateTime.Now; report.data_upload = DateTime.Now; report.data_ultimo_salvataggio = DateTime.Now; gm.Reports.Add(report); gm.SaveChanges(); }
public void TestNullMapping() { //Registering Mapping Mapper.Register <GeneralModel, GeneralViewModel>().Member(dest => dest.FullName, src => src.FirstName + src.LastName); var person = new GeneralModel(); Assert.IsNull(person.FirstName); Assert.IsNull(person.LastName); var personViewModel = (new GeneralModel()).Convert(); Assert.IsNotNull(personViewModel.FullName); Assert.AreEqual(personViewModel.FullName, string.Empty); }
private async Task <GeneralModel> GeneralModel() { var vmlist = new GeneralModel(); string general = url + "General/GetAllGeneral"; HttpResponseMessage responseMessage = await _client.GetAsync(general); if (responseMessage.IsSuccessStatusCode) { var responseData = responseMessage.Content.ReadAsStringAsync().Result; vmlist = JsonConvert.DeserializeObject <GeneralModel>(responseData); Common.VideoUrl = vmlist.About[0].VideoUrl; Common.GeneralModel = vmlist; } return(vmlist); }
public static Dictionary <string, string> getCultureIdioma() { Dictionary <string, string> datos = new Dictionary <string, string>(); String codPais = ""; DataTable dt = GeneralModel.getCultureIdioma(); foreach (DataRow dr in dt.Rows) { codPais = dr["CodPais"].ToString(); datos.Add(dr["CodEtiqueta"].ToString(), dr["Descripcion"].ToString()); } datos.Add(IdiomaCultura.CULTURE, codPais); return(datos); }