public static Family SpawnFamily() { Random random = new Random(DateTime.Now.Millisecond); int amount = random.Next(1, 5); List <Guest> guests = new List <Guest>(); List <string> names = new List <string> { "Nick", "Julia", "Piter", "Mark", "Smith" }; for (int i = 0; i < amount; i++) { if (i < 2) { guests.Add(new Guest(names[i], random.Next(19, 35))); } else { guests.Add(new Guest(names[i], random.Next(5, 17))); } } Family family = new Family(guests, random.Next(70, 600), LocalTime); Peoples.Add(family); return(family); }
public Peoples SaveAsync(Peoples cls) { try { var headers = Request.Headers?.ToList(); if (headers == null || headers.Count <= 0) { return(null); } var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault(); if (string.IsNullOrEmpty(guid)) { return(null); } var cusGuid = Guid.Parse(guid); if (!Assistence.CheckCustomer(cusGuid)) { return(null); } db.Peoples.AddOrUpdate(cls); db.SaveChanges(); Assistence.SaveLog(cusGuid, cls.Guid, EnTemp.Peoples); return(cls); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(null); } }
public void AddTag(IDmKeyword tagReference) { switch (tagReference.Type) { case TagType.Autor: Autors.Add((DmAutor)tagReference); break; case TagType.Category: Categories.Add((DmCategory)tagReference); break; case TagType.Genre: Genres.Add((DmGenre)tagReference); break; case TagType.People: Peoples.Add((DmPeople)tagReference); break; case TagType.Tag: Keywords.Add((DmKeyword)tagReference); break; case TagType.Collection: Collections.Add((DmCollection)tagReference); break; } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Peoples peoples) { if (id != peoples.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(peoples); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PeoplesExists(peoples.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.CartoonHeroes, "Id", "Name", peoples.Id); return(View(peoples)); }
public ActionResult <Users> Create(Peoples people) { var peopleDb = GetPerCpf(people.Cpf.ToString()); if (peopleDb.Value != null && people.Cpf == peopleDb.Value.Cpf) { return(BadRequest("Error: Já existe uma pessoa com esse cpf")); } var cepValid = VerifyCep(people); if (cepValid) { switch (people.Sexo) { case Sexo.Masculino: people.Sexo = Sexo.Masculino; break; case Sexo.Feminino: people.Sexo = Sexo.Feminino; break; } _peopleService.Create(people); return(CreatedAtRoute("GetPeople", new { id = people.Id }, people)); } return(BadRequest("CEP não existe em nosso banco de dados.")); }
public ActionResult NuevoRegistro(TablaViewsModels Model) { try { if (ModelState.IsValid) { using (ConectionsDataBase dataBase = new ConectionsDataBase()) { var persona = new Peoples(); persona.Nombre = Model.Nombre; persona.Apellido = Model.Apellido; persona.Edad = Model.Edad; persona.Sexo = Model.Sexo; persona.Correo = Model.Correo; dataBase.Peoples.Add(persona); dataBase.SaveChanges(); } return(Redirect("/")); } return(View(Model)); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task <IActionResult> Create([Bind("Id,Name")] Peoples peoples) { int counter = 0; foreach (var a in _context.Peoples) { if (a.Name == peoples.Name) { counter++; break; } } if (counter != 0) { ModelState.AddModelError("Name", "Така людина вже існує"); return(View(peoples)); } else { if (ModelState.IsValid) { _context.Add(peoples); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.CartoonHeroes, "Id", "Name", peoples.Id); return(View(peoples)); } }
public IActionResult Update(string id, Peoples peoplesIn) { var peopleDb = GetPerCpf(peoplesIn.Cpf.ToString()); if (peopleDb.Value != null && peoplesIn.Cpf == peopleDb.Value.Cpf) { return(BadRequest("Error: Já existe uma pessoa com esse cpf")); } var user = _peopleService.Get(id); if (user == null) { return(NotFound()); } var cepValid = VerifyCep(peoplesIn); if (cepValid) { peoplesIn.Id = id; _peopleService.Update(id, peoplesIn); return(Ok("Dados atualizados")); } return(BadRequest("CEP inexistente em nosso banco.")); }
public People PutPeople(People objCust) { People proj = Peoples.Where(x => x.Deleted == false).Where(x => x.PeopleID == objCust.PeopleID).FirstOrDefault(); if (proj != null) { proj.UpdatedDate = DateTime.Now; //proj.Client = objCust.Client; proj.PeopleFirstName = objCust.PeopleFirstName; proj.PeopleLastName = objCust.PeopleLastName; proj.Email = objCust.Email; proj.Department = objCust.Department; proj.BillableRate = objCust.BillableRate; proj.CostRate = objCust.CostRate; proj.Permissions = objCust.Permissions; proj.Type = objCust.Type; proj.ImageUrl = objCust.ImageUrl; proj.CreatedBy = objCust.CreatedBy; proj.CreatedDate = objCust.CreatedDate; proj.UpdateBy = objCust.UpdateBy; proj.EmailConfirmed = objCust.EmailConfirmed; Peoples.Attach(proj); this.Entry(proj).State = EntityState.Modified; this.SaveChanges(); return(objCust); } else { return(objCust); } }
public ProjectTask AddProjectTask(ProjectTask projecttask) { List <ProjectTask> projecttasks = ProjectTasks.Where(c => c.TaskId.Equals(projecttask.TaskId)).ToList(); Project prj = Projects.Where(x => x.ProjectID == projecttask.ProjectID).Select(x => x).FirstOrDefault(); People ppl = Peoples.Where(x => x.Deleted == false).Where(x => x.PeopleID == projecttask.PeopleID).Select(x => x).FirstOrDefault(); Customer cust = Customers.Where(x => x.CustomerId == projecttask.CustomerId).Select(x => x).FirstOrDefault(); ProjectTask objProjectTask = new ProjectTask(); if (projecttasks.Count == 0) { projecttask.CreatedBy = projecttask.CreatedBy; projecttask.CreatedDate = DateTime.Now; projecttask.UpdatedDate = DateTime.Now; //projecttask.ProjectName = projecttask.ProjectName; projecttask.ProjectName = prj.ProjectName; projecttask.CustomerName = cust.Name; projecttask.PeopleID = ppl.PeopleID; ProjectTasks.Add(projecttask); int id = this.SaveChanges(); return(projecttask); } else { //objProject.Exception = "Already"; return(objProjectTask); } //this.ProjectTasks.Add(projecttask); //this.SaveChanges(); //return projecttask; }
static void Main(string[] args) { const string db = "Database/Peoples"; FirebaseClient firebase = new FirebaseClient("https://csharp-localhost-default-rtdb.firebaseio.com/"); Peoples peoples = new Peoples("Gabriel Santos de Andrade", DateTime.Now); // ADD //var result = firebase.Child(db) // .PostAsync(JsonSerializer.Serialize(peoples)) // .GetAwaiter() // .GetResult(); // UPDATE - -MQZMuByH5vCRx_4QHBs //firebase.Child($"{db}/{"-MQZN6qN-A4EvkzQuCa0"}" ) // .PutAsync(JsonSerializer.Serialize(peoples)) // .GetAwaiter() // .GetResult(); // LIST var list = firebase.Child(db) .OnceAsync <Peoples>() .GetAwaiter() .GetResult(); foreach (var item in list) { System.Console.WriteLine("{0} - {1} {2}", item.Key, item.Object.Name, item.Object.CreatedAt); } }
public ActionResult SearchPerson(Peoples person) { if (person.City == null) { person.City = ""; } if (person.Address == null) { person.Address = ""; } if (person.PhoneNumber == null) { person.PhoneNumber = ""; } if (person.City == "" && person.Address == "" && person.PhoneNumber == "") { return(View("NoResults")); } List <Peoples> Persons = db.peoples.Where(p => p.City.Contains(person.City) && p.Address.Contains(person.Address) && p.PhoneNumber.Contains(person.PhoneNumber)).ToList(); if (Persons.Count == 0 || person == null) { return(View("NoResults")); } return(View(Persons)); }
public async Task <ResponseObject> Login(Login temp) { ResponseObject response = new ResponseObject(); if (!ModelState.IsValid) { response.Status = false; response.Message = "Model state is not valid."; return(response); } Peoples people = await db.Peoples.FirstOrDefaultAsync(x => x.Email.Equals(temp.Email.Trim()) && x.Password.Equals(temp.Password) && x.Type.Equals(temp.Type)); if (people == null) { response.Status = false; response.Message = "Username or Password is not right."; return(response); } else { response.Status = true; response.Message = "Login Successfull."; response.Data = await db.Peoples.Select(x => new { x.ID, x.Image, x.FullName, x.Email, x.Type }).FirstOrDefaultAsync(x => x.ID == people.ID); return(response); } }
private void BtnUpdate_Click(object sender, EventArgs e) { Peoples people = DatabaseContext?.Peoples.Find(Codigo); people.Name = TxtName.Text; DatabaseContext.SaveChanges(); Close(); }
/// <summary> /// /// </summary> /// <param name="peoples"></param> /// <returns>The Elements object.</returns> public Elements AddPeople(List <People> peoples) { foreach (var people in peoples) { Peoples.Add(people); } return(this); }
public ActionResult DeleteConfirmed(int id) { Peoples peoples = db.Peoples.Find(id); db.Peoples.Remove(peoples); db.SaveChanges(); return(RedirectToAction("Index")); }
public static PeopleModel GetModel(this Peoples item) { return(new PeopleModel() { Id = item.Id, IdPhoto = item.IdPhoto, Name = item.Name }); }
private void Form3_Load(object sender, EventArgs e) { Peoples people = DatabaseContext?.Peoples.Find(Codigo); if (people != null) { TxtId.Text = people.Id.ToString(); TxtName.Text = people.Name; } }
public int Create(Peoples people) { if (people == null) { throw new ArgumentNullException(); } db.Peoples.Add(people); db.SaveChanges(); return(people.Id); }
private void SetSessionForUser(Peoples loggedUser) { Session["UserID"] = loggedUser.PeoplesId.ToString(); Session["Username"] = loggedUser.Email.ToString(); Session["Fullname"] = loggedUser.FirstName.ToString() + " " + loggedUser.LastName.ToString(); if (loggedUser.IsAdmin) { Session["Admin"] = "true"; } }
public void AddPeople(People people) { if (people.IsBoss == true) { Bosses.Add(people); } else { Peoples.Add(people); } }
public ActionResult Edit([Bind(Include = "Id,People,Sities_Id")] Peoples peoples) { if (ModelState.IsValid) { db.Entry(peoples).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Sities_Id = new SelectList(db.Sities, "Id", "Sity", peoples.Sities_Id); return(View(peoples)); }
public ActionResult Edit([Bind(Include = "PeoplesId,FirstName,LastName,Identification,Password,PhoneNumber,Address,Email,City,BirthDate,IsAdmin")] Peoples peoples) //Password field removed { if (ModelState.IsValid) { db.Entry(peoples).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(peoples)); }
public string RemoveResource(int id) { try { var item = Resources.FirstOrDefault(i => i.ResourceID == id); Peoples.FirstOrDefault(i => i.PeopleID == item.PeopleID).Resources.Remove(item); Resources.Remove(item); SaveChanges(); return("Запись успешно удалена"); } catch (Exception ex) { return(ex.Message); } }
public void RemoveAll() { foreach (People people in Peoples) { Peoples.Remove(people); } foreach (Car car in Cars) { Cars.Remove(car); } DatabaseManager.GetInstance().SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,People,Sities_Id")] Peoples peoples) { if (ModelState.IsValid) { db.Peoples.Add(peoples); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Sities_Id = new SelectList(db.Sities, "Id", "Sity", peoples.Sities_Id); return(View(peoples)); }
public People getPersonIdfromEmail(string email) { People ps = new People(); ps = Peoples.Where(x => x.Deleted == false).Where(p => p.Email.Trim().Equals(email.Trim())).FirstOrDefault(); int id = 0; if (ps != null) { id = ps.PeopleID; } return(ps); }
public string RemovePeople(int id) { try { var item = Peoples.FirstOrDefault(i => i.PeopleID == id); Departments.FirstOrDefault(i => i.DepartmentID == item.DepartmentID).People.Remove(item); Organizations.FirstOrDefault(i => i.OrganizationID == item.OrganizationID).People.Remove(item); Positions.FirstOrDefault(i => i.PositionID == item.PositionID).People.Remove(item); Peoples.Remove(item); SaveChanges(); return("Запись успешно удалена"); } catch (Exception ex) { return(ex.Message); } }
// GET: Peoples/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Peoples peoples = db.Peoples.Find(id); if (peoples == null) { return(HttpNotFound()); } return(View(peoples)); }
async Task LoadData(String url) { if (IsBusy) { return; } Exception error = null; try { IsBusy = true; var resultPeoples = await Api.GetAllPeopleAsync(url); Next = resultPeoples.Next; if (url == null) { peoplesOriginal.Clear(); IsShowMore = true; } if (resultPeoples.Next == null) { IsShowMore = false; } peoplesOriginal.AddRange(resultPeoples.Peoples); Peoples.Clear(); foreach (var people in peoplesOriginal) { Peoples.Add(people); } } catch (Exception ex) { Debug.WriteLine("Error when load data: " + ex); error = ex; } finally { IsBusy = false; } if (error != null) { await ShowAlertAsync("Error when load data!", error.Message, "OK"); } }