public ActionResult Create(PracticeModel practice) { try { InitializePageData(); if (ModelState.IsValid) { if (practiceService.Exists(practice.PracticeName)) { DisplayWarningMessage($"The POD Name '{practice.PracticeName}' is duplicate"); return(View(practice)); } PracticeDto practiceModel = Mapper.Map <PracticeModel, PracticeDto>(practice); practiceService.CreatePractice(practiceModel); DisplaySuccessMessage($"New POD '{practice.PracticeName}' has been stored successfully"); return(RedirectToAction("List")); } } catch (Exception exp) { DisplayLoadErrorMessage(exp); } return(View(practice)); }
// GET: Practice/Edit/5 public ActionResult Edit(int?id) { PracticeModel practice = new PracticeModel(); InitializePageData(); try { if (!id.HasValue) { DisplayWarningMessage("Looks like, the ID is missing in your request"); return(RedirectToAction("List")); } if (!practiceService.Exists(id.Value)) { DisplayWarningMessage($"Sorry, We couldn't find the POD with ID: {id.Value}"); return(RedirectToAction("List")); } PracticeDto practiceDto = practiceService.GetPractice(id.Value); practice = Mapper.Map <PracticeDto, PracticeModel>(practiceDto); } catch (Exception exp) { DisplayReadErrorMessage(exp); } return(View(practice)); }
/// <summary> /// /// </summary> /// <param name="practiceDto"></param> /// <param name="noteDto"></param> /// <returns></returns> public async Task <int> CreatePractice(PracticeDto practiceDto) { //Map to the DB entity Practice practiceDb = Mapper.Map <Practice>(practiceDto); //Obtain the team name var teamDb = await _db.GetAsync <Team>(new Team() { Id = practiceDto.TeamId }); practiceDb.Side = teamDb?.Name; //1. Insert into the Practice table await _db.InsertAsync(practiceDb); if (practiceDb.Id == 0) { return(0); } //2. Insert into PracticeDrill table foreach (var drill in practiceDto.PracticeDrills) { var drillDb = Mapper.Map <PracticeDrill>(drill); drillDb.PracticeId = practiceDb.Id; await _db.InsertAsync(drillDb); } return(practiceDb.Id); }
public ActionResult Edit(int id, PracticeModel practice) { try { InitializePageData(); if (ModelState.IsValid) { if (practiceService.Exists(practice.PracticeName, practice.PracticeID)) { DisplayWarningMessage($"POD Name '{practice.PracticeName}' is duplicate"); return(View(practice)); } PracticeDto practiceModel = Mapper.Map <PracticeModel, PracticeDto>(practice); practiceService.UpdatePractice(practiceModel); DisplaySuccessMessage($"POD '{practice.PracticeName}' details have been modified successfully"); return(RedirectToAction("List")); } } catch (Exception exp) { DisplayUpdateErrorMessage(exp); } return(View(practice)); }
private void practicedata_CurrentItemChanged(object sender, CurrentItemChangedEventArgs e) { PracticeDto previousItem = e.PreviousItem as PracticeDto; PracticeDto currentItem = e.CurrentItem as PracticeDto; MessagingCenter.Send(this, "TEST2", currentItem); }
public Practice CreatePractice(PracticeDto practiceDto) { var newPractice = _mapper.Map <Practice>(practiceDto); _db.Practices.Add(newPractice); _db.SaveChanges(); return(newPractice); }
public void Add(PracticeDto entity) { Practice practice = CreateBusinessEntity(entity, true); Entities.Add(practice); DataContext.Entry(practice).State = EntityState.Added; DataContext.SaveChanges(); }
public ConfirmBookingViewModel(Doctor enquiredDoctor, PracticeDto _medicalBuildingModel, string _FullDateAndMonth) { // 1) Xamlbindings. // 2) One method to handle all bindings & keep things neat XamlBindings(enquiredDoctor, _medicalBuildingModel, _FullDateAndMonth); NavigateToHomePageCommand = new Command(ConfirmBooking); }
private void MigrateEntity(PracticeDto sourceEntity, Practice targetEntity) { targetEntity.BusinessUnitID = sourceEntity.BusinessUnitID; targetEntity.PracticeName = sourceEntity.PracticeName; targetEntity.ShortName = sourceEntity.ShortName; targetEntity.PracticeID = sourceEntity.PracticeID; targetEntity.ManagerID = sourceEntity.ManagerID; targetEntity.UpdateTimeStamp(sourceEntity.LoggedInUserName); }
public void IsValid() { var item = new PracticeDto() { Name = Guid.NewGuid().ToString(), }; Assert.IsTrue(item.IsValid()); }
public void IsInvalid() { var item = new PracticeDto() { Name = string.Empty, }; Assert.IsFalse(item.IsValid()); }
/// <summary> /// Removes item with the specified id. /// </summary> /// <typeparam name="T">The type of the item to remove</typeparam> /// <param name="id">The id of the item to remove.</param> public void Remove(PracticeDto item) { Assert.IsNotNull(item, "item"); if (!this.CanRemove(item)) { throw new ReferencialIntegrityException(); } this.Remove <Practice>(item); }
private void XamlBindings(Doctor enquiredDoctor, PracticeDto _medicalBuildingModel, string _FullDateAndMonth) { SelectedDoctor = enquiredDoctor; SelectedMedicalBuilding = _medicalBuildingModel; PracticeName = _medicalBuildingModel.PracticeName; LastName = enquiredDoctor.LastName; Debug.WriteLine(" Doctor Recieved => [" + enquiredDoctor.ToString() + "]" + "MedicalBuildingModel Recieved" + "[" + _medicalBuildingModel + "]" + "FullDateAndMonth Recieved" + "[" + _FullDateAndMonth + "]"); ConvertTimeDate(_FullDateAndMonth); }
public void Delete(PracticeDto entity) { Practice buzEntity = Entities.FirstOrDefault(e => e.PracticeID == entity.PracticeID); buzEntity.IsDeleted = true; buzEntity.UpdateTimeStamp(entity.LoggedInUserName); Entities.Add(buzEntity); DataContext.Entry(buzEntity).State = EntityState.Modified; DataContext.SaveChanges(); }
public SelectBooking(PracticeDto _MedicalBuildingData) { InitializeComponent(); BindingContext = new SelectBookingViewModel(_MedicalBuildingData); MessagingCenter.Subscribe <SelectBookingViewModel, SelectedMonths>(this, "ItemSelected", (obj, item) => { DisplayAlert("Alert", "You've choosen the date " + item.MonthValue, "cancel"); DateSelected = item.MonthValue.ToString(); }); }
public async Task <IActionResult> Get([FromRoute] PracticeQuery practice) { try { PracticeDto pDto = await _dispatcher.QueryAsync <PracticeDto>(practice); return(Ok(pDto)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public static PracticeDto CreatePracticeDto(PracticeInformation practice) { PracticeDto newDto = new PracticeDto() { PracticeID = practice.Id, ContactNumber = practice.ContactPractice.PracticeTelephoneNumber, PracticeName = practice.PracticeName, NumberOfPatientsAtPractice = practice.NumOfPatientsInPractice, OperatingTimes = practice.OperatingTime, PracticePicture = practice.PracticePicture }; return(newDto); }
private Practice CreateBusinessEntity(PracticeDto categoryDto, bool isNewEntity = false) { Practice practice = new Practice { BusinessUnitID = categoryDto.BusinessUnitID, PracticeName = categoryDto.PracticeName, ShortName = categoryDto.ShortName, PracticeID = categoryDto.PracticeID, ManagerID = categoryDto.ManagerID }; practice.UpdateTimeStamp(categoryDto.LoggedInUserName, true); return(practice); }
public void UpdatePractice(PracticeDto practiceDto) { // remove previously saved schedules var schedules = _db.Schedules.Where(x => x.PracticeId == practiceDto.Id); _db.Schedules.RemoveRange(schedules); // remove passed schedules with zero minutes practiceDto.Schedules = practiceDto.Schedules.Where(x => x.Minutes > 0); // save practice var practice = _db.Practices.Find(practiceDto.Id); _mapper.Map(practiceDto, practice); _db.SaveChanges(); }
/// <summary> /// Create the specified item into the database /// </summary> /// <param name="reputation">The item to add in the database</param> public long Create(PracticeDto item) { Assert.IsNotNull(item, "item"); var exist = (from i in this.Session.Query <Practice>() where item.Name.ToUpper() == i.Name.ToUpper() || i.Id == item.Id select i).ToList().Count() > 0; if (exist) { throw new ExistingItemException(); } var entity = Mapper.Map <PracticeDto, Practice>(item); item.Id = (long)this.Session.Save(entity); return(item.Id); }
public async Task <IActionResult> UpdatePractice([FromBody, Required] PracticeDto practiceDto) { try { if (practiceDto == null) { return(BadRequest()); } var result = await _service.UpdatePractice(practiceDto); return(CreatedAtRoute("default", result)); } catch (Exception ex) { Log.Error(ex, ex.Message); return(BadRequest(ex.Message)); } }
public async Task <bool> UpdatePractice(PracticeDto practiceDto) { //Get the practice by its Id var dbRec = new Practice() { Id = practiceDto.Id }; var practiceDb = await _db.GetAsync(dbRec); //store practice Id into a temp var var practiceId = practiceDb.Id; //Map to the Database object practiceDb = Mapper.Map <Practice>(practiceDto); //Update ID practiceDb.Id = practiceId; return(await _db.UpdateAsync(practiceDb)); }
/// <summary> /// Determines whether the specified item can be removed. /// </summary> /// <param name="item">The item.</param> /// <returns> /// <c>true</c> if this instance can remove the specified item; otherwise, <c>false</c>. /// </returns> public bool CanRemove(PracticeDto item) { return((from t in this.Session.Query <Patient>() where t.Practice.Id == item.Id select t).Count() == 0); }
public static void SetPractice(DependencyObject target, PracticeDto value) { target.SetValue(PracticeProperty, value); }
public ConfirmBooking(Doctor enquiredDoctor, PracticeDto _medicalBuildingData, string FullDateAndMonth) { InitializeComponent(); viewModel = new ConfirmBookingViewModel(enquiredDoctor, _medicalBuildingData, FullDateAndMonth); BindingContext = viewModel; }
/// <summary> /// Determines whether the specified item can be removed. /// </summary> /// <param name="item">The item.</param> /// <returns> /// <c>true</c> if this instance can remove the specified item; otherwise, <c>false</c>. /// </returns> public bool CanRemove(PracticeDto item) { return(new Remover(this.Session).CanRemove(item)); }
/// <summary> /// Updates the specified practice. /// </summary> /// <param name="practice">The drug.</param> public void Update(PracticeDto practice) { new Updator(this.Session).Update(practice); }
/// <summary> /// Removes item with the specified id. /// </summary> /// <typeparam name="T">The type of the item to remove</typeparam> /// <param name="id">The id of the item to remove.</param> public void Remove(PracticeDto item) { new Remover(this.Session).Remove(item); }
/// <summary> /// Creates the specified practice. /// </summary> /// <param name="practice">The drug.</param> public long Create(PracticeDto practice) { return(new Creator(this.Session).Create(practice)); }
private void TLScrollView_ItemSelected(object sender, ItemTappedEventArgs e) { PracticeDto _medicalBuildingModelData = e.Item as PracticeDto; Navigation.PushAsync(new SelectBooking(_medicalBuildingModelData)); }