public ActionResult SearchMethod(ParentModel model) { var name = model.Name; var childName = model.ChildModel.Name; return(View(model)); }
protected override ParentDto ConvertCore(int childId) { ParentModel parentModel = _parentModels[childId]; MappingEngine mappingEngine = (MappingEngine)Mapper.Engine; return(mappingEngine.Map <ParentModel, ParentDto>(parentModel)); }
public ActionResult Dashboard() { // check if logged in if (Session["parent"] == null) { return(View("Login")); } ParentModel parent = Session["parent"] as ParentModel; parent.Children = parentDAL.GetChildren(parent.Parent_ID); // add mascots to child list foreach (ChildModel child in parent.Children) { child.Mascot = mascotDAL.GetMascot(child); if (activityDAL.IdExists(child.Child_Id)) { child.TotalSteps = activityDAL.GetSteps(child.Child_Id); child.TotalMinutes = activityDAL.GetMinutes(child.Child_Id); } else { child.TotalSteps = 0; child.TotalMinutes = 0; } } return(View("Dashboard", parent)); }
protected void OnParentViewModelChanged() { try { ParentModel = ParentViewModel.ToString().Split('_')[0]; if (ParentModel.Equals("CoinTradingViewModel")) { HeaderVisible = Visibility.Collapsed; } else if (ParentModel.Equals("TradeHistoryTradingViewModel")) { HeaderVisible = Visibility.Collapsed; } else if (ParentModel.Equals("ExchangeDashboardViewModel")) { HeaderVisible = Visibility.Visible; } else { HeaderVisible = Visibility.Collapsed; } if (HeaderVisible == Visibility.Collapsed) { HeaderHeight = 0; AmtVisible = false; } } catch (Exception ex) { SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace); } }
public ActionResult Index(ParentModel model) { if (ModelState.IsValid) { // Do saving and stuff foreach (var childModel in model.Children) { // See if we should be adding this or saving? if (childModel.Id == 0) { // Insert / Add, check if there is any data first (check required fields) if (!string.IsNullOrWhiteSpace(childModel.MyProperty)) { // Insert into DB now } } else { // } } // Normally we'd return here to read from DB but for sample we're just going to fall through and mimic the base action //return RedirectToAction(nameof(Index), new { model.Id }); } // Ensure we have a new editor row present always model.Children.Add(new ChildModel()); return(View(model)); }
public ActionResult Update(ParentModel pm, String ImgUrl, String Departments, String Price) { double price; if (!double.TryParse(Price, out price)) { Price = Price.Replace('.', ','); } try { price = double.Parse(Price); Item item = new Item(Departments, pm.Item.ItemName) { ImgURL = ImgUrl, ItemName = pm.Item.ItemName, Price = price, Description = pm.Item.Description, ETag = "*" }; Item exists = StorageManager.GetItem(item.RowKey); if (exists != null) { StorageManager.UpdateItem(item); } else { StorageManager.DeleteItem(pm.Item); StorageManager.AddItem(item); } return(RedirectToAction("Feedback", "Home", new { message = item.ItemName + " Successfully Updated", isSuccess = true, redirectControl = "Storage", redirectAction = "ListItems" })); } catch (Exception e) { return(RedirectToAction("Feedback", "Home", new { message = "Failed to add Item. " + e.Message, isSuccess = false, redirectControl = "Storage", redirectAction = "ListItems" })); } }
public void Update() { ParentDisplayModel exists = Parents.Where(x => x.Id == SelectedParent.Id).FirstOrDefault(); if (exists != null) { if (SelectedParent != null && Parents.Count > 0) { isUpdating = true; ParentModel e = new ParentModel { Id = SelectedParent.Id, FirstName = _firstName, LastName = _lastName, Phone = _phone, Email = _email }; SqlDataAccess sql = new SqlDataAccess(); sql.UpdateData <ParentModel>("dbo.spParent_Update", e, "ADBData"); msg = $"Parent ({SelectedParent.FullName}) was successfully updated."; MessageBox.Show(msg, "Parent Updated"); Parents = new BindingList <ParentDisplayModel>(GetAllParents()); Clear(); isUpdating = false; } } _events.PublishOnUIThread(new ParentChangedEvent()); }
protected override void Establish_context() { _parent = new ParentModel { ID = 2 }; List <ChildModel> childModels = new List <ChildModel> { new ChildModel { ID = 1, Parent = _parent } }; Dictionary <int, ParentModel> parents = childModels.ToDictionary(x => x.ID, x => x.Parent); Mapper.CreateMap <int, ParentDto>().ConvertUsing(new ChildIdToParentDtoConverter(parents)); Mapper.CreateMap <int, List <ChildDto> >().ConvertUsing(new ParentIdToChildDtoListConverter(childModels)); Mapper.CreateMap <ParentModel, ParentDto>() .ForMember(dest => dest.Children, opt => opt.MapFrom(src => src.ID)); Mapper.CreateMap <ChildModel, ChildDto>(); Mapper.AssertConfigurationIsValid(); }
public bool Update(ParentModel entity) { try { var currentEntity = _dbContext.Set <ParentModel>().AsQueryable().FirstOrDefault(x => x.ParentId == entity.ParentId); if (currentEntity == null) { return(false); } currentEntity.ParentName = entity.ParentName; currentEntity.ParentAddress1 = entity.ParentAddress1; currentEntity.ParentAddress2 = entity.ParentAddress2; //currentEntity.ParentEmail = entity.ParentEmail; currentEntity.ParentPostCode = entity.ParentPostCode; currentEntity.ParentTelephone = entity.ParentTelephone; if (entity.ImageFileUrl != null) { currentEntity.ImageFileUrl.Url = entity.ImageFileUrl.Url; } return(true); } catch (Exception ex) { LogException(ex); throw ex; } }
public ActionResult AddChildAc(ParentModel Model) { List <tblRelashionship> SRlist = Connection.tblRelashionships.Where(X => X.IsActive == "Y").ToList(); ViewBag.RelationshipList = new SelectList(SRlist, "RelashionshipId", "RelashionshipName"); List <tblSchool> Schoollist = Connection.tblSchools.Where(X => X.IsActive == "Y").ToList(); ViewBag.SchoolDrpDown = new SelectList(Schoollist, "SchoolId", "SchoolName"); List <tblGrade> gradelist = Connection.tblGrades.Where(X => X.IsActive == "Y").ToList(); ViewBag.SchoolGradeList = new SelectList(gradelist, "GradeId", "GradeName"); List <tblClass> Classlist = Connection.tblClasses.Where(X => X.IsActive == "Y").ToList(); ViewBag.classDrpDown = new SelectList(Classlist, "ClassId", "ClassName"); List <tblStudent> Studentlist = Connection.tblStudents.Where(X => X.IsActive == "Y" && X.SchoolId == USession.School_Id).ToList(); ViewBag.StudentIdList = new SelectList(Studentlist, "StudentId", "StudentName"); var STQlist = Connection.SMGTgetParentStudentadd(Model.ParentId, "%").ToList(); List <ParentModel> List = STQlist.Select(x => new ParentModel { StudentId = x.StudentId, ParentName = x.ParentName, ParentId = x.ParentId.ToString(), StudentName = x.studentName }).ToList(); return(View()); }
protected override void OnInitialize() { base.OnInitialize(); Shell = ParentModel.Shell; //если установили фильтр по мнн нужно сбросить поисковый запрос что бы отобразить все //товары с таким мнн ParentModel.ObservableForProperty(m => m.FilterByMnn).Where(x => x.Value) .Subscribe(_ => SearchBehavior.ActiveSearchTerm.Value = ""); //после закрытия формы нужно отписаться от событий родительской формы //что бы не делать лишних обновлений ParentModel.ObservableForProperty(m => (object)m.FilterByMnn) .Merge(ParentModel.ObservableForProperty(m => (object)m.CurrentFilter)) .Merge(ParentModel.ObservableForProperty(m => (object)m.ShowWithoutOffers)) .Merge(SearchBehavior.ActiveSearchTerm.Cast <Object>()) .Throttle(TimeSpan.FromMilliseconds(30), Scheduler) .Do(_ => IsLoading.Value = true) .Select(_ => RxQuery(LoadData)) .Switch() .Do(_ => IsLoading.Value = false) .Subscribe(Items, CloseCancellation.Token); Items.Subscribe(_ => { CurrentItem.Value = (Items.Value ?? Enumerable.Empty <CatalogDisplayItem>()).FirstOrDefault(); }); }
//todo: если поставить фокус в строку поиска и ввести запрос //для товара который не отображен на экране //то выделение переместится к этому товару но прокрутка не будет произведена public IResult EnterCatalogName() { if (CurrentCatalogName.Value == null || Catalogs.Value.Count == 0) { return(null); } if (!ParentModel.ViewOffersByCatalog) { if (!CurrentCatalogName.Value.HaveOffers) { return(new ShowPopupResult(() => ParentModel.ShowOrderHistory())); } Shell.Navigate(new CatalogOfferViewModel(CurrentCatalogName.Value)); return(null); } if (Catalogs.Value.Count == 1) { CurrentCatalog = Catalogs.Value.First(); return(EnterCatalog()); } return(new FocusResult("Catalogs")); }
public ParentModel UpdateParent(Guid id, ParentModel model) { try { var parentModel = GetById(id); if (parentModel != null) { // TODO: Refactor this to extension parentModel.ParentId = model.ParentId; parentModel.FullName = model.FullName; parentModel.Email = model.Email; parentModel.Cellphone = model.Cellphone; parentModel.IDNumber = model.IDNumber; parentModel.Nationality = model.Nationality; parentModel.Address = model.Address; parentModel.Gender = model.Gender; parentModel.ModifyUserId = model.ModifyUserId; parentModel.ModifyDate = model.ModifyDate; parentModel.StatusId = model.StatusId; _repo.Parent.Update(parentModel.ToEntity()); _repo.Save(); return(parentModel); } else { return(null); } } catch (Exception e) { Console.WriteLine(e); throw; } }
public Response RegisterParent([FromBody] ParentModel parentModel) { Response ans = null; try { if (ValidateSecurityAPI()) { ans = ParentModel.RegisterParent(parentModel); } else { ans = new Response() { IsSuccessful = false, ResponseMessage = AppManagement.MSG_API_Validation_Failure }; } } catch (Exception ex) { ans = new Response() { IsSuccessful = false, ResponseMessage = AppManagement.MSG_GenericExceptionError }; } return(ans); }
public async Task AddParent(ParentModel parentModel) { var parent = Mapper.Map <ParentModel, Parent>(parentModel); var school = Repositories.Schools.GetById(parentModel.SchoolId); if (school == null) { throw new TargetException("School not found"); } parent.School = school; foreach (var childId in parentModel.ChildrenId) { var child = Repositories.Students.GetById(childId); if (child == null) { throw new TargetException("Student not found"); } parent.Children.Add(child); } var account = await _accountService.RegisterSchoolUser(parent); if (account == null) { return; } parent.User = account; parent.Id = account.Id; Repositories.Parents.Create(parent); }
public Response Login([FromBody] ParentModel Parent) { Response ans = null; try { if (ValidateSecurityAPI()) { //ParentModel parent = JsonConvert.DeserializeObject<ParentModel>(Parent); ans = ParentModel.Login(Parent); } else { ans = new Response() { IsSuccessful = false, ResponseMessage = AppManagement.MSG_API_Validation_Failure }; } } catch (Exception ex) { ans = new Response() { IsSuccessful = false, ResponseMessage = AppManagement.MSG_GenericExceptionError }; } return(ans); }
public ResponseParent GetParent(string identification) { ResponseParent ans = null; try { if (ValidateSecurityAPI()) { ans = ParentModel.GetParent(identification); } else { ans = new ResponseParent() { IsSuccessful = false, ResponseMessage = AppManagement.MSG_API_Validation_Failure }; } } catch (Exception ex) { ans = new ResponseParent() { IsSuccessful = false, ResponseMessage = AppManagement.MSG_GenericExceptionError }; } return(ans); }
private ParentModel GetModel() { var gridModels = new List <GridModel>(); for (int i = 0; i < 5; i++) { var gridModel = new GridModel(); gridModel.ID = i; gridModel.Data = "data"; gridModel.DataDisabledNegative = "data"; gridModel.DataDisabledPositive = "data"; gridModel.DataEnabledNegative = "data"; gridModel.DataEnabledPositive = "data"; gridModel.DataVisibleNegative = "data"; gridModel.DataVisiblePositive = "data"; gridModel.DataHiddenNegative = "data"; gridModel.DataHiddenPositive = "data"; gridModel.HiddenData = "data"; gridModels.Add(gridModel); } var model = new ParentModel(); model.DisplayGrid = gridModels; model.SingleSelectGrid = gridModels; model.MultipleSelectGrid = gridModels; return(model); }
public void GetSelectorMetadataTest() { var model = new GridModel(); var parentModel = new ParentModel(); var modelMetadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(model, model.GetType()); var parentModelPropertyMetadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(parentModel, parentModel.GetType()); var parentModelPropertiesMetadata = parentModelPropertyMetadata as List <ModelMetadata> ?? parentModelPropertyMetadata.ToList(); var modelPropertiesMetadata = modelMetadata as List <ModelMetadata> ?? modelMetadata.ToList(); ModelMetadata actual = GridHelper.GetSelectorMetadata(modelPropertiesMetadata.FirstOrDefault(), modelPropertiesMetadata, parentModelPropertiesMetadata.FirstOrDefault(), parentModelPropertiesMetadata); Assert.IsNull(actual); var s = parentModelPropertiesMetadata.First(p => p.PropertyName == "SingleSelectGrid"); ModelMetadata actual1 = GridHelper.GetSelectorMetadata(modelPropertiesMetadata.FirstOrDefault(), modelPropertiesMetadata, s, parentModelPropertiesMetadata); Assert.IsNotNull(actual1); Assert.IsTrue(actual1.ContainerType == typeof(ParentModel)); var m = parentModelPropertiesMetadata.First(p => p.PropertyName == "MultipleSelectGrid"); ModelMetadata actual2 = GridHelper.GetSelectorMetadata(modelPropertiesMetadata.FirstOrDefault(), modelPropertiesMetadata, m, parentModelPropertiesMetadata); Assert.IsNotNull(actual2); Assert.IsTrue(actual2.ContainerType == typeof(GridModel)); }
public void Can_Render_Complex_Model_Properties() { var model = new ParentModel { ParentName = new NameDetails { Firstname = "Luke", Surname = "Dinosaur" }, ChildrenNames = new List <NameDetails> { new NameDetails { Firstname = "ChildFirstA", Surname = "ChildLastA" }, new NameDetails { Firstname = "ChildFirstB", Surname = "ChildLastB" } } }; var expected = @" Parent: Luke Children: * ChildFirstA ChildLastA * ChildFirstB ChildLastB "; var email = Email .From(TestData.FromEmail) .To(TestData.ToEmail) .Subject(TestData.Subject) .UsingTemplate(Template(), model); email.Data.Body.Should().Be(expected); }
public ActionResult myIndex() { var user = db.Users.Find(User.Identity.GetUserId()); if (User.IsInRole("Submitter")) { var myT = db.Tickets.Where(t => t.OwnerUserId == user.Id).Include(t => t.AssignedTo).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); return(View(myT.ToList())); } else if (User.IsInRole("Developer")) { var myTicForDev = db.Tickets.Where(t => t.AssignedToId == user.Id).Include(t => t.AssignedTo).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); return(View(myTicForDev.ToList())); } else if (User.IsInRole("ProjectManager")) { var parentM = new ParentModel(); var Devs = db.Roles.FirstOrDefault(r => r.Name == "Developer"); var uList = db.Users.Where(u => u.Roles.Any(r => r.RoleId == Devs.Id)).ToList(); ViewBag.Developer = new SelectList(uList, "Id", "FirstName"); var myTicForPM = db.Tickets.Where(u => u.Project.PManagerID == user.Id).Include(t => t.AssignedTo).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); parentM.DevUser = uList; parentM.tickets = myTicForPM; return(View(parentM)); } //ViewData["Developer"] = new SelectList(uList, "Id", "Name"); ParentModel pmodel = new ParentModel(); var tickets = db.Tickets.Include(t => t.AssignedTo).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); pmodel.tickets = tickets; return(View(pmodel)); }
public async Task <IdentityResult> RegisterParent(ParentModel parent, string password) { var result = await _userManager.CreateAsync(parent, password); _userManager.AddToRole(parent.Id, "parents"); return(result); }
public ActionResult Edit(ParentModel p) { try { AnswerToQuestionContext ans = new AnswerToQuestionContext(); QuestionContext qt = new QuestionContext(); int qId = ans.GetMaxId() + 1; DateTime date = DateTime.ParseExact(p.Question.Date, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); qt.CreateQuestion(qId, p.Question.Question, date); foreach (var item in p.AnswersCollection) { if (!string.IsNullOrWhiteSpace(item.Text)) { ans.CreateAnswerToTheQuestions(qId, item.Text); } } return(RedirectToAction("Index")); } catch (Exception) { return(View()); } }
public ParentModel GetParent(string emailAddress) { ParentModel parent = null; try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(SQL_GetParent, conn); cmd.Parameters.AddWithValue("@email", emailAddress); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { parent = new ParentModel { Email = Convert.ToString(reader["email"]), First_Name = Convert.ToString(reader["first_name"]), Last_Name = Convert.ToString(reader["last_name"]), Parent_ID = Convert.ToInt32(reader["parent_id"]), Password = Convert.ToString(reader["p_word"]), Salt = Convert.ToString(reader["salt"]), }; } } } catch (SqlException e) { throw; } return(parent); }
private ParentModel MapParentModel(Parent parent, ParentProfile profile, ParentAlert parentAlert) { var parentModel = new ParentModel(); parentModel.ParentUniqueId = parent.ParentUniqueId; if (profile != null) { SetParentContactInfo(parentModel, profile); } if (profile == null || parentModel.Email == null) { SetParentContactInfo(parentModel, parent); } if (parentAlert == null) { return(parentModel); } parentModel.ParentAlert.PreferredMethodOfContactTypeId = profile?.PreferredMethodOfContactTypeId; parentModel.ParentAlert.AlertTypeIds = parentAlert.AlertTypes.Select(x => x.AlertTypeId).ToList(); parentModel.LanguageCode = profile.LanguageCode; return(parentModel); }
public async Task <IActionResult> Put(Guid id, [FromBody] ParentModel model) { try { var userId = User.Identity.Name; if (userId != null) { model.ModifyUserId = Guid.Parse(userId); model.ModifyDate = DateTime.Now; var result = _parentService.UpdateParent(id, model); if (result != null) { return(Ok(result)); } else { return(null); } } return(BadRequest("An error has occurred, please contact system administrator!")); } catch (Exception e) { throw new Exception(e.Message); } }
public void Update(ParentModel parentModel) { var id = parentModel.Id; _propertyValueService.Update(id, "ParentBirthDate", parentModel.BirthDate.ToString()); _propertyValueService.Update(id, "ParentName", parentModel.Name); }
private void SetParentContactInfo(ParentModel parentModel, Parent parent) { var preferredMail = parent.ParentElectronicMails.FirstOrDefault(x => x.PrimaryEmailAddressIndicator.HasValue && x.PrimaryEmailAddressIndicator.Value); var mail = preferredMail ?? parent.ParentElectronicMails.FirstOrDefault(); parentModel.Email = mail?.ElectronicMailAddress; }
public ParentDto Convert(ResolutionContext resolutionContext) { int childId = (int)resolutionContext.SourceValue; ParentModel parentModel = _parentModels[childId]; MappingEngine mappingEngine = (MappingEngine)Mapper.Engine; return(mappingEngine.Map <ParentModel, ParentDto>(resolutionContext, parentModel)); }
// GET: AnswerCharacteristics public ViewResult AnswerCharacteristics() { var charac = new CharacteristicsContext(); ParentModel ch = new ParentModel(); ch.CharacteristicsToAnswersCollection = charac.GetListOfAllCharacteristicsWithTheyAnswers(); return(View(ch)); }