public string GetConfirmationCode(string username, string password, string email) //retorna JSON { string response = string.Empty; EngineProyect Funcion = new EngineProyect(); if (username == null || username == string.Empty || password == null || password == string.Empty || email == null || email == string.Empty) { return(response = Funcion.BuildingVerificationCode(string.Empty, HttpStatusCode.NotImplemented.ToString()));//Modelo incompleto 501 } EngineDb Metodo = new EngineDb(); bool resultado = Metodo.GetUser(username, password, email); if (!resultado) { return(response = Funcion.BuildingVerificationCode(string.Empty, HttpStatusCode.ExpectationFailed.ToString()));//No existe el usuario 417 } string code = Funcion.NumberFactory(); CodeToVerification model = new CodeToVerification(); model = Funcion.BuildingVerificationCode(username, password, email, code, false); EngineDb Entidad = new EngineDb(this.context); resultado = Entidad.InsertCodeToVerification(model); if (!resultado) { return(response = Funcion.BuildingVerificationCode(string.Empty, HttpStatusCode.Conflict.ToString()));//No inserto el codigo 409 } return(response = Funcion.BuildingVerificationCode(code, HttpStatusCode.OK.ToString())); }
public static string LoginUser(string user, string password, string session) { ResponseWM response = new ResponseWM(); password = EngineTool.ConvertirBase64(user + password); EngineDb Method = new EngineDb(); bool result = Method.LoginUser(user, password); if (result) { System.Web.HttpContext.Current.Session["User"] = user; if (session == "si") { EngineProject Function = new EngineProject(); Function.CreateGalleta(); } response.Description = "Autentificacion Exitosa"; response.Result = true; } else { response.Description = "Autentificacion Fallida"; response.Result = false; System.Web.HttpContext.Current.Session["User"] = null; } return(JsonConvert.SerializeObject(response)); }
public static string EmployeeListReady() { EngineDb Metodo = new EngineDb(); List <Employee> model = Metodo.GetEmployees(); return(JsonConvert.SerializeObject(model)); }
public static string ExtendSearchText(string textSearch) { EngineDb Metodo = new EngineDb(); List <Employee> model = Metodo.ExtendSearchText(textSearch); return(JsonConvert.SerializeObject(model)); }
public static void Main() { IInputReader consoleReader = new ConsoleReader(); var consoleWriter = new ConsoleWriter { AutoFlush = true }; ICommandDispatcher commandDispatcher = new CommandDispatcher(); IGroupFactory groupFactory = new GroupFactory(); IWarEffectFactory warEffectFactory = new WarEffectFactory(); IAttackFactory attackFactory = new AttackFactory(); IDatabase db = new EngineDb(); var engine = new Engine( consoleReader, consoleWriter, commandDispatcher, groupFactory, warEffectFactory, attackFactory, db); engine.Start(); }
public HttpResponseMessage PostCreateUser([FromBody] User create) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); if (create == null) { return(response = new HttpResponseMessage(HttpStatusCode.NotImplemented));//Modelo incompleto 501 } EngineProyect Funcion = new EngineProyect(); bool resultado = false; resultado = Funcion.CompareString(create.SignatureApp, EngineData.SignatureApp); if (!resultado) { return(response = new HttpResponseMessage(HttpStatusCode.ExpectationFailed));//No es la firma 417 } EngineDb Metodo = new EngineDb(); resultado = Metodo.InsertUser(create); if (!resultado) { response = new HttpResponseMessage(HttpStatusCode.NotAcceptable); //No pudo crearse usuario 406 response.Content = new StringContent(Metodo.Failure()); //Informacion especifica del error return(response); } response.Headers.Location = new Uri(EngineData.UrlBase + EngineData.EndPointLogin); return(response); }
public static string ExtendSearchDate2(string dateInit, string dateEnd) { ResponseWM response = new ResponseWM(); EngineDb Metodo = new EngineDb(); List <Employee> model = Metodo.ExtendSearchDate(Convert.ToDateTime(dateInit), Convert.ToDateTime(dateEnd)); return(JsonConvert.SerializeObject(model)); }
public void AddEntityInFile() { // Arrange FileHelper.DeleteFile(_filePath); var engine = new EngineDb(_filePath); var firstCar = Car.Create(2007, "Renault"); // Act engine.AddEntity(firstCar); engine.SaveAll(); var entity1Result = engine.Find <Car>(1); // Assert Assert.NotNull(entity1Result); }
protected void createEmployee_Click(object sender, EventArgs e) { string Result = "Fallo registrar empleado"; try { string valueHour = rate.Value; if (string.IsNullOrEmpty(valueHour)) { valueHour = "0.0"; } valueHour = valueHour.Replace('.', ','); string nation = nacionalidad.Value; bool result = EngineTool.EmailEsValido(email.Text); if (!result) { Result = "Email no valido"; } else { Employee model = new Employee() { IdentificationNumber = nation + identificationNumber.Text, FirstName = firstName.Text, LastName = lastName.Text, Email = email.Text, Phone = phone.Text, Direccion = direccion.Text, ContractDate = Convert.ToDateTime(contractDate.Value), BirthDate = Convert.ToDateTime(birthDate.Value), FreeLance = freeLance.Checked, Rate = float.Parse(valueHour) }; EngineDb Metodo = new EngineDb(); result = Metodo.CreateEmployee(model); if (result) { Result = "Empleado registrado satisfactoriamente"; } } } catch { } ScriptManager.RegisterStartupScript(this, this.GetType(), "Result", "Result('" + Result + "');", true); }
public static string DeleteEmployee(string id) { ResponseWM response = new ResponseWM(); EngineDb Metodo = new EngineDb(); bool result = Metodo.DeleteEmployee(id); if (result) { response.Result = true; } else { response.Result = false; } return(JsonConvert.SerializeObject(response)); }
public static string EditEmployee(string id, string name, string lastName, string email) { ResponseWM response = new ResponseWM(); EngineDb Metodo = new EngineDb(); bool result = Metodo.EditEmployee(id, name, lastName, email); if (result) { response.Result = true; } else { response.Result = false; } return(JsonConvert.SerializeObject(response)); }
public void LargeAddRead() { // Arrange FileHelper.DeleteFile(_filePath); var engine = new EngineDb(_filePath); for (int i = 0; i < 1000; i++) { var car = Car.Create(i, "Audi"); // Act engine.AddEntity(car); } engine.SaveAll(); Car[] results = new Car[2]; results[0] = engine.Find <Car>(1); results[1] = engine.Find <Car>(2); }
private bool AuthenticateUser(User login) { bool resultado = false; EngineDb Metodo = new EngineDb(); EngineProyect Funcion = new EngineProyect(); User user = new User(); user = Metodo.GetUser(login); string entry = Funcion.ConvertirBase64(login.Username + login.Password); bool comparacion = Funcion.CompareString(user.Password, entry); if (!comparacion) { return(resultado); } user.Token = GenerateJSONWebToken(user); resultado = true; return(resultado); }
public string PutActivateAcount([FromBody] CodeToVerification act)//retorna JSON { string response = string.Empty; EngineProyect Funcion = new EngineProyect(); if (act.Username == null || act.Username == string.Empty || act.Password == null || act.Password == string.Empty || act.Email == null || act.Email == string.Empty || act.Code == null || act.Code == string.Empty) { return(response = Funcion.BuildingVerificationCode(string.Empty, HttpStatusCode.NotImplemented.ToString())); } EngineDb Metodo = new EngineDb(); bool resultado = false; resultado = Metodo.PutActivateAccount(act); if (!resultado) { return(response = Funcion.BuildingVerificationCode(act.Code, HttpStatusCode.Conflict.ToString()));//No Actualizo el codigo 409 } return(response = Funcion.BuildingVerificationCode(act.Code, HttpStatusCode.OK.ToString())); }
public static string CreateAdministrator(string name, string lastName, string user, string password) { ResponseWM response = new ResponseWM(); response.Description = "Fallo crear administrador"; response.Result = false; try { password = EngineTool.ConvertirBase64(user + password); EngineProject Funcion = new EngineProject(); Administrator adm = Funcion.SetAdministrator(name, lastName, user, password); EngineDb Metodo = new EngineDb(); bool result = Metodo.CreateAdministrator(adm); if (result) { response.Description = "Administrador creado satisfactoriamente"; response.Result = true; } } catch { } return(JsonConvert.SerializeObject(response)); }
public void AddTwoEntityInFile() { // Arrange FileHelper.DeleteFile(_filePath); var engine = new EngineDb(_filePath); var firstCar = Car.Create(2007, "Renault"); var secondCar = Car.Create(2018, "Audi"); // Act engine.AddEntity(firstCar); engine.AddEntity(secondCar); engine.SaveAll(); Car[] results = new Car[2]; results[0] = engine.Find <Car>(1); results[1] = engine.Find <Car>(2); // Assert Assert.NotNull(results[0]); Assert.Equal("Renault", results[0].Brand); Assert.NotNull(results[1]); Assert.Equal("Audi", results[1].Brand); }
static void Main(string[] args) { // Arrange if (File.Exists(_filePath)) { File.Delete(_filePath); } var engine = new EngineDb(_filePath); Task task1 = Task.Factory.StartNew(() => { for (int i = 0; i < 10000; i++) { var car = Car.Create(i, "Audi"); // Act engine.AddEntity(car); } }); Task task2 = Task.Factory.StartNew(() => { for (int i = 0; i < 10000; i++) { var car = Car.Create(i, "Renauld"); // Act engine.AddEntity(car); } }); Task.WaitAll(task1, task2); engine.SaveAll(); Car[] results = new Car[2]; results[0] = engine.Find <Car>(1); results[1] = engine.Find <Car>(2); }