//[HttpPost] public async Task <IActionResult> TblAppointments_ReadJson(string storeId, string filterFromDate) //string storeId, string filterFromDate) { int sId = int.Parse(storeId); DateTime datFilterFromDate = DateTime.Now; bool success = DateTime.TryParse(filterFromDate, CultureInfo.GetCultureInfo("de-DE"), DateTimeStyles.None, out datFilterFromDate); RestAccess ra = new RestAccess(Constants.ServiceClientEndPointWithApiPrefix); var shop = await ra.GetMeetingsForDate(sId, datFilterFromDate.Date); var slots = shop.Result.Where(a => a.Id == -1).ToList(); List <AppointmentEntryViewModel> lstAppointmentEntryViewModels = new List <AppointmentEntryViewModel>(); int id = 1; foreach (var exMeeting in slots) { var employee = _context.TblEmployees.First(x => x.Id == exMeeting.Staff.Id); AppointmentEntryViewModel vm = new AppointmentEntryViewModel(); vm.Id = id++; vm.EmployeeName = exMeeting.Staff.Name; vm.StartTime = exMeeting.Start.AddHours(2); vm.EndTime = exMeeting.End.AddHours(2); vm.ShopId = sId; vm.OptionalText = ""; vm.PreviewText = employee.DefaultAnnotation; vm.StaffId = exMeeting.Staff.Id; vm.ImageUrl = string.IsNullOrEmpty(exMeeting.Staff.ImageUrl) ? "" : exMeeting.Staff.ImageUrl; lstAppointmentEntryViewModels.Add(vm); } return(Json(lstAppointmentEntryViewModels)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,OptionalText,ShopId,StartTime,EndTime,StaffId")] AppointmentEntryViewModel app) { //if (id != tableAppointment.Id) //{ // return NotFound(); //} int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var tbUser = await _context.TblUsers.AsNoTracking().FirstOrDefaultAsync(a => a.Id == userId); RestAccess ra = new RestAccess(tbUser.Id.ToString(), tbUser.RestPasswort, Constants.ServiceClientEndPointWithApiPrefix); var response = await ra.SetMeetingWeb(new ExSaveMeetingRequest { OptionalText = app.OptionalText, LocationId = app.ShopId, StartTime = app.StartTime.ToUniversalTime(), StaffId = app.StaffId, UserId = userId, CheckPassword = WebAppSettings.CheckPassword, }); if (response.Ok && response.Result != null) { if (response.Result.Result == EnumSaveDataResult.Error) { ViewData["message"] = response.Result.Description; return(View(app)); } TempData["message"] = "Dein Termin wurde erfolgreich bestätigt."; return(RedirectToAction("Index", "MyAppointments")); } ViewData["message"] = "Es konnte keine Verbindung zum Server hergestellt werden."; return(View(app)); }
// GET: ChooseAppointment/Edit/5 public async Task <IActionResult> Edit(int?id, string storeId, string selectedDate) { if (TempData["message"] != null) { ViewData["message"] = TempData["message"]; } if (id == null) { return(NotFound()); } int sId = int.Parse(storeId); // this is the location id... DateTime datSelectedDate = DateTime.Now.ToLocalTime(); try { var ddatSelectedDate = DateTime.Parse(selectedDate, CultureInfo.GetCultureInfo("de-DE")); datSelectedDate = ddatSelectedDate; } catch (Exception e) { return(Json("false")); } int userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var tbUser = await _context.TblUsers.AsNoTracking().FirstOrDefaultAsync(a => a.Id == userId); RestAccess ra = new RestAccess(tbUser.Id.ToString(), tbUser.RestPasswort, Constants.ServiceClientEndPointWithApiPrefix); var shop = await ra.GetMeetingsForDate(sId, datSelectedDate.Date.AddHours(2)); var slots = shop.Result.Where(a => a.Id == -1).ToList(); List <AppointmentEntryViewModel> lstAppointmentEntryViewModels = new List <AppointmentEntryViewModel>(); var exMeeting = slots[id.Value - 1]; AppointmentEntryViewModel vm = new AppointmentEntryViewModel(); vm.Id = 0; vm.EmployeeName = exMeeting.Staff.Name; vm.EndTime = exMeeting.End; vm.OptionalText = ""; var res = await ra.GetDefaultText(exMeeting.Staff.Id); if (res != null && res.Result != null) { vm.PreviewText = res.Result.PlaceholderText; } else { vm.PreviewText = ""; } vm.ShopId = sId; vm.StaffId = exMeeting.Staff.Id; vm.StartTime = exMeeting.Start; return(View(vm)); }