private void SaveBtn_Clicked(object sender, RoutedEventArgs e) { var photographer = new PhotographerViewModel(); var birthday = DateTime.Now; if (DateTime.TryParse(Birthday.Text, out birthday)) { if (birthday < DateTime.Now && !string.IsNullOrWhiteSpace(FirstName.Text) && !string.IsNullOrWhiteSpace(LastName.Text) && !string.IsNullOrWhiteSpace(Notes.Text)) { photographer.BirthDay = birthday; photographer.FirstName = FirstName.Text; photographer.LastName = LastName.Text; photographer.Notes = Notes.Text; Controller.SavePhotographer(photographer); this.Close(); } else { ErrorLabel.Content = "INVALID INPUT"; } } else { ErrorLabel.Content = "INVALID INPUT"; } }
public ActionResult ViewPhotographer(int ID) { var model = new PhotographerViewModel(); model.Photographer = _databaseService.GetPhotographerByID(ID); // Get all instances of the photographer. var PhotographerInstances = _databaseService.GetPhotographers().Where(x => x.Name == model.Photographer.Name && x.Email == model.Photographer.Email && x.FormID != 1 && x.ContactNumber == model.Photographer.ContactNumber); // For each instance, add a row to the table listing the forms the photographer is part of. var Forms = new List <ConsentFormModel>(); foreach (var Instance in PhotographerInstances) { Forms.Add(_databaseService.GetFormByID(Instance.FormID)); } model.Forms.Table.Columns.Add("View", typeof(HtmlString)); model.Forms.Table.Columns.Add("Project Name", typeof(string)); model.Forms.Table.Columns.Add("Date Created", typeof(string)); foreach (var Form in Forms) { var ViewLink = new HtmlString(string.Format("<a type=\"button\" class=\"btn btn-primary btn-sm\" href=\"../ViewForm/{0}\">View</a>", Form.FormID)); model.Forms.Table.Rows.Add(ViewLink, Form.ProjectName, Form.DateCreated); } return(View(model)); }
private void BtnSaveChanges_Click(object sender, RoutedEventArgs e) { if (lastSelectedViewModel == null) { return; } if (DateTime.TryParse(Birthday.Text, out DateTime birthday)) { if (birthday < DateTime.Now && !string.IsNullOrWhiteSpace(FirstName.Text) && !string.IsNullOrWhiteSpace(LastName.Text) && !string.IsNullOrWhiteSpace(Notes.Text)) { PhotographerViewModel photographerViewModel = lastSelectedViewModel; photographerViewModel.FirstName = FirstName.Text; photographerViewModel.LastName = LastName.Text; photographerViewModel.BirthDay = DateTime.Parse(Birthday.Text); photographerViewModel.Notes = Notes.Text; Controller.UpdatePhotographer(photographerViewModel); } else { ErrorLabel.Content = "INVALID INPUT"; } } else { ErrorLabel.Content = "INVALID INPUT"; } }
public AssignPhotographerWindow(MainWindowViewModel mainWindowViewModel, PhotographerViewModel photographerViewModel, Picture pic) { _mainWindowViewModel = mainWindowViewModel; _photographerViewModel = photographerViewModel; _pic = pic; DataContext = photographerViewModel; InitializeComponent(); }
public PhotographerModel(PhotographerViewModel pvm) { ID = pvm.ID; FirstName = pvm.FirstName; LastName = pvm.LastName; Notes = pvm.Notes; Birthday = pvm.Birthday; }
// GET api/photographers public IHttpActionResult Get() { var photographers = new PhotographerViewModel { Photographers = photographerService.GetAll() }; return(Json(photographers)); }
private void AddPhotographer(object sender, RoutedEventArgs e) { var photographer = new PhotographerViewModel(); photographer.FirstName = fn.Text; photographer.LastName = ln.Text; photographer.Notes = notes.Text; photographer.Birthday = bd.SelectedDate; _controller.savePhotographer(photographer); }
private void PhotographerBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (PhotographerBox.SelectedItem != null) { var PhotographerModel = (PhotographerViewModel)PhotographerBox.SelectedItem; lastSelectedViewModel = PhotographerModel; FirstName.Text = PhotographerModel.FirstName; LastName.Text = PhotographerModel.LastName; Birthday.Text = PhotographerModel.BirthDay.ToString(); Notes.Text = PhotographerModel.Notes; } ErrorLabel.Content = ""; }
public PhotographerAddWindow(PhotographerViewModel photographerViewModel, bool edit) { _photographerViewModel = photographerViewModel; _edit = edit; DataContext = photographerViewModel; if (edit) { Title = "Edit Photographer"; } else { Title = "Add Photographer"; } InitializeComponent(); }
public async Task <IActionResult> Save([FromForm] PhotographerViewModel model) { if (model.Id == null) { await _service.Add(model); } else { _service.Update(model); } if (IsOperationValid()) { return(RedirectToAction(nameof(Index))); } return(View("AddOrEdit", model)); }
public void Save(PhotographerViewModel phVM) => Save(phVM.PhotographerModel);
public HttpResponseMessage Add(PhotographerViewModel photographer) { photographerService.Add(Mapper.Map <PhotographerDto>(photographer)); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public void Update(PhotographerViewModel model) { Bus.SendCommand(new UpdatePhotographerCommand(Guid.Parse(model.Id), model.Name, model.Email)); }
public Task Add(PhotographerViewModel model) { return(Bus.SendCommand(new AddPhotographerCommand(model.Name, model.Email))); }