public IActionResult CreatePerson() { PersonVM personVM = new PersonVM(); personVM.Cities = _cityService.AllCities(); return(View(personVM)); }
private void BtnRemove_Click(object sender, RoutedEventArgs e) { if (dgShow.SelectedItem != null) { PersonVM user = null; try { user = (PersonVM)dgShow.SelectedItem; } catch (Exception) { return; } Entities.Person dbUserRemove = _db.People.SingleOrDefault(u => u.Id == user.Id); if (dbUserRemove != null) { _db.People.Remove(dbUserRemove); _db.SaveChanges(); _people.Remove(user); } } }
public async Task <IActionResult> CreateOrEdit(Guid id) { var isNew = false; var bo = await _BoRepository.GetSingleAsyn(id, x => x.Department); if (bo == null) { bo = new Person(); bo.Name = ""; bo.Email = ""; bo.Mobile = ""; bo.Description = ""; bo.SortCode = ""; isNew = true; } var boVM = new PersonVM(bo); boVM.IsNew = isNew; #region 创建供归属部门选择器使用的元素集合 var depts = _BoRepository.EntitiesContext.Departments.ToList(); var selectItems = SelfReferentialItemFactory <Department> .GetCollection(depts, true); boVM.ParentItemCollection = selectItems; #endregion return(View("../../Views/BusinessOrganization/Person/CreateOrEdit", boVM)); }
public ActionResult CreateOrEdit(Guid id) { bool isNew = false; var bo = _Service.GetSingle(id); if (bo == null) { bo = new Person(); bo.ID = id; isNew = true; } var boVM = new PersonVM(bo); boVM.ParentItemColection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(true); boVM.CredentialsTypeCollection = BusinessCollectionFactory <CredentialsType> .GetPlainFacadeItemCollection(); boVM.JobLevelCollection = BusinessCollectionFactory <JobLevel> .GetPlainFacadeItemCollection(); boVM.JobTitleCollection = BusinessCollectionFactory <JobTitle> .GetPlainFacadeItemCollection(); var editor = PageComponentRepository <PersonVM> .CreateOrEditDialog(boVM, isNew); return(Json(editor)); }
public ActionResult EditPerson(PersonVM model) { if (ModelState.IsValid) { using (var context = new LabEntities()) { Person editedPerson = new Person { Id = model.Id, LastName = model.LastName, FirstName = model.FirstName, Patronymic = model.Patronymic, Gender = model.Gender, Age = model.Age, HasJob = model.HasJob }; context.People.Attach(editedPerson); context.Entry(editedPerson).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } return(RedirectToAction("ListOfPeople")); } ViewBag.Genders = new SelectList(GetGendersList(), "Item1", "Item2"); return(View(model)); }
public IActionResult PersonDetail(int id) { Person person = _bookcontext.People.Include(q => q.BookPeople).ThenInclude(BookPeople => BookPeople.Book).ThenInclude(BookPeople => BookPeople.BookPersons).Include(q => q.PersonDuties).FirstOrDefault(q => q.ID == id); PersonVM model = new PersonVM(); model.Name = person.Name; model.SurName = person.SurName; model.BirthDate = person.BirthDate; model.Biography = person.Biography; model.Duties = person.PersonDuties.Where(q => q.IsDeleted == false).Select(q => q.DutyID == Convert.ToInt32(EnumDuty.Writer) ? EnumDuty.Writer.ToString() : EnumDuty.Interpreter.ToString()).ToList(); model.Imagepath = person.Imagepath; model.BookPeople = person.BookPeople; List <Category> modelcategory = _bookcontext.Categories.Where(q => q.IsDeleted == false).OrderBy(q => q.CategoryName).ToList(); List <Person> modelpeople = _bookcontext.People.Include(q => q.BookPeople.Where(q => q.DutyID == 0)).Where(q => q.IsDeleted == false).OrderBy(q => q.Name).ToList(); SiteBookVM sitebook = new SiteBookVM(); sitebook.Categories = modelcategory; sitebook.people = modelpeople; sitebook.PersonDetail = model; return(View(sitebook)); }
static void Main(string[] args) { asda Register(); Person p = new Person(); p.getAllPersons(); IEnumerable <PersonVM> result = Mapper.Map <IEnumerable <PersonVM> >(p.getAllPersonsAsync().Result); foreach (var item in result) { Console.WriteLine(item.Wiek); Console.WriteLine(item.Name); Console.WriteLine(item.Surname); } PersonVM pvm = Mapper.Map <PersonVM>(p); IEnumerable <PersonVM> pvmx = Mapper.Map <IEnumerable <PersonVM> >(p.getAllPersons()); foreach (var item in pvmx) { Console.WriteLine(item.Wiek); Console.WriteLine(item.Name); Console.WriteLine(item.Surname); } Console.ReadKey(); }
/// <summary> /// 保存人员数据 /// </summary> /// <param name="perVM"></param> /// <returns></returns> public async Task <IActionResult> Save([Bind("ID,IsNew,Name,Email,FixedTelephone,Description,SortCode")] PersonVM perVM) { var hasDuplicateNamePerson = await _PersonExtension.HasInstanceAsyn(x => x.Name == perVM.Name); if (hasDuplicateNamePerson && perVM.IsNew) //判断是否已存在该人员 { ModelState.AddModelError("", "人员名重复,无法添加"); //添加指定的错误信息 return(View("../../Views/BusinessOrganization/Person/CreateOrEdit", perVM)); } var bo = new Person(); if (!perVM.IsNew) { bo = await _PersonRepository.GetSingleAsyn(perVM.ID); } perVM.MapToBo(bo); var saveStatus = await _PersonRepository.AddOrEditAndSaveAsyn(bo); if (saveStatus) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "数据保存出现异常,无法处理,请联系开发部人员。"); return(View("../../Views/BusinessOrganization/Person/CreateOrEdit", perVM)); } }
public static LoginInfoVM queryLoginPersonByPersonId(int personId) { LoginInfoVM info = null; using (DatabaseModel.ErrorModelDbContext db = new DatabaseModel.ErrorModelDbContext()) { // Initialize the DB - false doesn't force reinitialization if the DB already exists db.Database.Initialize(false); var query = (from n in db.LoginSet where n.OnePerson.PersonId == personId select n).First(); PersonVM person = new PersonVM() { PersonId = query.OnePerson.PersonId, FirstName = query.OnePerson.FirstName, LastName = query.OnePerson.LastName, Email = query.OnePerson.Email }; info = new LoginInfoVM() { LoginId = query.LoginId, LoginTime = query.LoginTime, Password = query.Password, Role = query.Role, IsLive = query.IsLive, OnePerson = person }; } return(info); }
public IActionResult Add(PersonVM model, int[] jobs) { if (ModelState.IsValid) { Person person = new Person(); person.Name = model.name; person.SurName = model.surname; person.BirthDate = model.birthdate; person.Country = model.country; _context.People.Add(person); _context.SaveChanges(); int PersonID = person.ID; foreach (var item in jobs) { PersonJob personJob = new PersonJob(); personJob.PersonID = PersonID; personJob.JobID = item; _context.PersonJobs.Add(personJob); } _context.SaveChanges(); return(Redirect("/Admin/Person/Index")); } else { return(View(getJobs())); } }
public ActionResult Index(int?page, string vl, string prm = null) { PersonRepository repository = new PersonRepository(); try { Search search = new Search(); search = SetValue(page, vl, prm); int pageSize = 15; int pageNumber = (page ?? 1); PersonVM viewModel = new PersonVM(); viewModel.Search = search; viewModel.Search.pageSize = pageSize; viewModel.Search.pageNumber = pageNumber; viewModel.RPersonList = repository.SW_GetPersons(viewModel.Search); viewModel.ListCount = repository.SW_GetPersonsCount(viewModel.Search); int[] pc = new int[viewModel.ListCount]; viewModel.Paging = pc.ToPagedList(pageNumber, pageSize); return(Request.IsAjaxRequest() ? (ActionResult)PartialView("PartialIndex", viewModel) : View(viewModel)); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Error", "Error"))); } }
private PersonVM populateDropDownList(PersonVM viewModel) { viewModel.GenderTypeList = EnumService.GetEnumTypesByParent((int)TypeEnum.GenderType); viewModel.PersonTypeList = EnumService.GetEnumTypesByParent((int)TypeEnum.PersonType); return(viewModel); }
/// <summary> /// Populate Person from a ViewModel /// </summary> /// <param name="inVM"></param> public void fromViewModel(PersonVM inVM) { this.personID = inVM.personID; this.firstName = inVM.firstName; this.lastName = inVM.lastName; this.relation = inVM.relation; }
public async Task <ActionResult <PersonVM> > GetPerson(int id) { //var person = await _context.Persons.FindAsync(id); var person = await _context.Persons .Include(s => s.Addresses) .AsNoTracking() .FirstOrDefaultAsync(m => m.NationalID == id); if (person == null) { return(NotFound()); } var pv = new PersonVM { NationalID = person.NationalID, FirstMidName = person.FirstMidName, BirthDate = GetPersianDate(person.BirthDate), LastName = person.LastName, Addresses = person.Addresses, PersonPicture = person.PersonPicture }; return(pv); }
private void ClickSelection() { ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000f)) { tmpGameObject = hit.transform.gameObject; //click on empty field if (!hit.transform.gameObject.GetComponent <PersonVM>()) { ClearListOfPersons(); return; } personVM = hit.transform.gameObject.GetComponent <PersonVM>(); if ((!selected.Contains(tmpGameObject)) && (Input.GetKey(KeyCode.LeftControl))) { Select(); } else if (!selected.Contains(tmpGameObject)) { ClearListOfPersons(); Select(); } else { Deselect(); } } }
public async Task <PersonVM> PutAsync(PersonVM person) { var newPersonVM = iMapper.Map <PersonVM, Person>(person); var newPerson = await unitOfWork.PersonRepository.AddOrUpdateAsync(newPersonVM); return(iMapper.Map <Person, PersonVM>(newPerson)); }
public ViewResult profile(string Username) { Username = Session["UserId"].ToString(); if (Username != null) { if (ModelState.IsValid) { PERSON p = new PERSON() { user_id = Username, }; PERSON per = obj.GetByID(p.user_id); Session["joinDate"] = per.joined; PersonVM Pvm = new PersonVM() { Username = per.user_id, Pwd = per.password, Name = per.fullName, Email = per.email }; return(View(Pvm)); } else { return(View()); } } else { return(View("Login")); } }
public PersonVM[] GetOnePerson(string intressent_id) { List <PersonVM> listOfPersonVM = new List <PersonVM>(); try { sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = "GetDataPerson"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Connection = sqlConnection; InParam(sqlCommand, "@intressent_id", intressent_id, 20, SqlDbType.NVarChar); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { PersonVM personVM = new PersonVM(); personVM.Id = (string)sqlDataReader["intressent_id"]; personVM.FirstName = (string)sqlDataReader["fornamn"]; personVM.LastName = (string)sqlDataReader["efternamn"]; personVM.Party = (string)sqlDataReader["parti"]; personVM.Constituency = (string)sqlDataReader["valkrets"]; personVM.Vote = (string)sqlDataReader["rost"]; personVM.ParliamentaryYear = (string)sqlDataReader["rm"]; personVM.Abscense = (decimal)sqlDataReader["Procent"]; listOfPersonVM.Add(personVM); } } finally { sqlConnection.Close(); } return(listOfPersonVM.ToArray()); }
public ActionResult signup(PersonVM item) { if (ModelState.IsValid) { PERSON p = new PERSON() { user_id = item.Username, password = item.Pwd, email = item.Email, fullName = item.Name, active = true, joined = DateTime.Now }; List <string> listAllUsers = obj.GetAllUserId(p.user_id); if (listAllUsers.Count > 0) { Session["ExistingUser"] = "******"; return(View()); } else { obj.AddUser(p); return(RedirectToAction("Login")); } } else { return(View()); } }
public ActionResult CreatePerson(PersonVM newPerson) { if (ModelState.IsValid) { using (var context = new LabEntities()) { Person person = new Person { Id = Guid.NewGuid(), LastName = newPerson.LastName, FirstName = newPerson.FirstName, Patronymic = newPerson.Patronymic, Gender = newPerson.Gender, Age = newPerson.Age, HasJob = newPerson.HasJob }; context.People.Add(person); context.SaveChanges(); } return(RedirectToAction("ListOfPeople")); } ViewBag.Genders = new SelectList(GetGendersList(), "Item1", "Item2"); return(View(newPerson)); }
public void CreateNewInstructor_NewInstructor_NewInstructorCreated() { //Arrange PersonVM modelTest = new PersonVM() { LastName = "Green", FirstMidName = "Harry", Login = "******", Password = "******", ConfirmPassword = "******", Role = "instructor" }; //Ceci rend le test dependant de la methode GenerateSHA256String(string inputString) de la Classe HashService string passwordTest = HashService.GenerateSHA256String(modelTest.Password); //Act authenticationBusinessToTest.CreateNewInstructor(modelTest); Instructor instructor = DBUtils.db.Instructors.SingleOrDefault(s => s.LastName == "Green" && s.FirstMidName == "Harry" && s.Login == "login1" && s.Password == passwordTest); //Assert Assert.IsNotNull(instructor); }
public PersonVM Update(PersonVM person) { var model = converter.Parse(person); var vm = converter.Parse(repo.Update(model)); return(vm); }
public ActionResult FollowUser(PersonVM collection) { try { Following f = new Following() { UserId = collection.UserId, FollowerUserId = Session["UserId"].ToString() }; obj.AddFollowers(f); Person objPerson = new Person(); objPerson = obj.GetUser(Session["SerchText"].ToString()); PersonVM personVM = new PersonVM() { UserId = objPerson.UserId, Name = objPerson.Name, Pwd = Decrypt(objPerson.Pwd).ToString(), Email = objPerson.Email, ProfileImage = objPerson.ProfileImage, Joined = objPerson.Joined, Active = objPerson.Active, status = "" }; return(RedirectToAction("Index", "Home")); } catch (Exception Ex) { Logger.WriteError(Ex, "FollowUser", "User"); return(View("Error")); } }
public ActionResult Create([FromForm] PersonVM submittedPerson) { try { if (ModelState.IsValid) { var personModel = new PersonModel() { FirstName = submittedPerson.FirstName, LastName = submittedPerson.LastName, EmailAddress = submittedPerson.EmailAddress, }; var res = new PersonDA().CreatePerson(personModel); if (res == 1) // means one row effected. which is created { return(RedirectToAction(nameof(Index))); } else { return(View()); } } else { return(View()); } } catch { return(View()); } }
public ActionResult PersonnalInformtion(PersonVM model) { List <SelectListItem> nationalality = new List <SelectListItem>() { new SelectListItem { Text = "Pakistan", Value = "Pakistan", Selected = true }, }; List <SelectListItem> educationLevel = new List <SelectListItem>() { new SelectListItem { Text = "High School", Value = "High School", Selected = true }, new SelectListItem { Text = "Diploma", Value = "Diploma" }, new SelectListItem { Text = "Bachelor's degree", Value = "Bachelor's degree" }, new SelectListItem { Text = "Master's degree", Value = "Master's degree" }, new SelectListItem { Text = "Doctorate", Value = "Doctorate" }, }; model.ListEducationalLevel = educationLevel; model.ListNationality = nationalality; currentPerson = model.IDPers; return(View(model)); }
public ActionResult Index(string typeID) { var pageIndex = 1; var pageSize = 18; if (String.IsNullOrEmpty(typeID)) { typeID = _DepartmentService.GetSingleBy(x => x.ParentDapartment.ID == x.ID).ID.ToString(); } var dID = Guid.Parse(typeID); var boCollection = _Service.Paginate(pageIndex, pageSize, x => x.SortCode, x => x.Department.ID == dID); var paginate = new MucPaginate(boCollection.PageIndex, boCollection.PageSize, boCollection.TotalCount); var boVMCollection = new List <PersonVM>(); int count = 0; foreach (var item in boCollection) { var boVM = new PersonVM(item); boVM.OrderNumber = (++count).ToString(); boVMCollection.Add(boVM); } var leftNavigatorItemCollection = BusinessCollectionFactory <Department> .GetSelfReferentialItemCollection(false); // 创建页面模型 var pageModel = PageModelRepository <PersonVM> .GetPageMode(boVMCollection, leftNavigatorItemCollection, paginate); return(View("../../Views/Admin/Common/Index", pageModel)); }
private void RadioButton_Checked(object sender, RoutedEventArgs e) { if (dgShow.SelectedItem != null) { PersonVM user = null; try { user = (PersonVM)dgShow.SelectedItem; } catch (Exception) { return; } RadioButton button = (RadioButton)sender; if (button.IsChecked == true) { Entities.Person personForChange = _db.People.SingleOrDefault(p => p.Id == user.Id); if ((string)button.Content == "male") { personForChange.Gender = "Male"; user.IsMale = true; user.IsFemale = false; } else { personForChange.Gender = "Female"; user.IsMale = false; user.IsFemale = true; } _db.SaveChanges(); } } }
public JsonResult AddToModel(PersonVM person) { //var trainingData = DataUtils.SeedTrainingData(); var trainingData = ctx.People.ToList(); var probmatrix = DataUtils.GetFeatureProb(trainingData); var eduObj = probmatrix.FirstOrDefault(x => x.VarName == VariableNames.Education.ToString() && x.LevelName == person.EducationVM); var ageObj = probmatrix.FirstOrDefault(x => x.VarName == VariableNames.Age.ToString() && x.LevelName == person.AgeVM); var sexObj = probmatrix.FirstOrDefault(x => x.VarName == VariableNames.Sex.ToString() && x.LevelName == person.SexVM); var yProb = eduObj.LevelYAdjProb * ageObj.LevelYAdjProb * sexObj.LevelYAdjProb; var nProb = eduObj.LevelNAdjProb * ageObj.LevelNAdjProb * sexObj.LevelNAdjProb; var acceptence = yProb > nProb?TargetLevels.Yes.ToString() : TargetLevels.No.ToString(); if (person.PersistData) { //trainingData.Add(new Person() {Education = education,Age=age,Sex=sex,Acceptence = usePred ? acceptence : ViewBag.Result}); var newOne = new Person() { Education = person.EducationVM, Age = person.AgeVM, Sex = person.SexVM, Acceptence = person.UsePrediction ? acceptence : person.AcceptenceVM }; ctx.People.Add(newOne); ctx.SaveChanges(); } return(Json(person.UsePrediction ? acceptence : person.AcceptenceVM)); }
public ActionResult AddPersonnalInformtion(PersonVM person) { if (ModelState.IsValid) { //Creating Mapping Mapper.Initialize(cfg => cfg.CreateMap <PersonVM, Person>()); Person personEntity = Mapper.Map <Person>(person); HttpPostedFileBase file = Request.Files["ImageProfil"]; bool result = _resumeRepository.AddPersonnalInformation(personEntity, file); if (result) { Session["IdSelected"] = _resumeRepository.GetIdPerson(person.FirstName, person.LastName); return(RedirectToAction("Education")); } else { ViewBag.Message = "Something Wrong !"; return(View(person)); } } ViewBag.MessageForm = "Please Check your form before submit !"; return(View(person)); }
public async Task <ActionResult> Post([FromBody] PersonVM person) { if (string.IsNullOrEmpty(person.FullName)) { return(BadRequest()); } return(Ok(await service.Handle(person))); }