예제 #1
0
        public IActionResult Post([FromBody] ClassDetailViewModel model)
        {
            // add it to the db
            try
            {
                if (ModelState.IsValid)
                {
                    var newClassDetail = _mapper.Map <ClassDetailViewModel, ClassDetail>(model);

                    var isCallSuccess = _repository.AddClassDetail(newClassDetail);
                    if (isCallSuccess && _repository.SaveAll())
                    {
                        return(Created($"/api/classdetail/{newClassDetail.Id}", _mapper.Map <ClassDetail, ClassDetailViewModel>(newClassDetail)));
                    }
                    else
                    {
                        return(BadRequest("Classdetail's can't be added for existing lastname"));
                    }
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to save a new ClassDetail: {ex}");
            }

            return(BadRequest("Failed to save new ClassDetail"));
        }
예제 #2
0
        // GET: Classes/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var @class = await _context.Class
                         .Include(c => c.Style)
                         .Include(c => c.Attendance_Classes)
                         .ThenInclude(ac => ac.Student)
                         .FirstOrDefaultAsync(m => m.Id == id);

            if (@class == null)
            {
                return(NotFound());
            }

            ClassDetailViewModel thisClass = new ClassDetailViewModel
            {
                Class   = @class,
                ClassId = (int)id,
            };

            thisClass.sortByDates = (
                from ac in @class.Attendance_Classes
                group ac by ac.Date into DateGroup
                select new GroupAttendanceHashSet
            {
                Key = DateGroup.Key,
                Attendees = DateGroup.ToList()
            }).ToList();

            return(View(thisClass));
        }
예제 #3
0
        public ActionResult StudentRegistration(ClassDetailViewModel model)
        {
            Context db                            = new Context();
            string  options                       = string.Empty;
            string  pickuppharase                 = string.Empty;
            bool    showdeliveryoptions           = false;
            bool    showShippingInDeliveryOptions = false;
            int     shippingDays                  = 0;
            string  subdomain                     = Request.Url.Host.Split(new char[] { '.' })[0];
            string  paypalemail                   = db.EnrolSetting.Where(x => x.SiteName == subdomain).Select(x => x.PaypalEmail).FirstOrDefault();
            double  optionsprice                  = 0;

            if (model.SelectedAddOns != null && model.SelectedAddOns.Length > 0)
            {
                options = String.Join(",", model.SelectedAddOns);
                int   compannyid = 0;
                int[] addons     = Array.ConvertAll(options.Split(','), int.Parse);
                IEnumerable <RegistrationAdOn> lstAddOns = db.RegistrationAdOn.Where(x => addons.Contains(x.AdOnID));
                compannyid          = lstAddOns.ToList()[0].CompanyID;
                optionsprice        = lstAddOns.Select(x => x.Price).Sum();
                showdeliveryoptions = lstAddOns.Any(x => x.Type == "Shippable");
                if (showdeliveryoptions)
                {
                    AdOnDeliveryOption delvroptions = db.AdOnDeliveryOption.Where(x => x.CompanyID == compannyid).FirstOrDefault();
                    if (delvroptions != null && !string.IsNullOrWhiteSpace(delvroptions.PickupText))
                    {
                        DateTime allowShippingTill = DateTime.Now.Date.AddDays(Convert.ToInt32(delvroptions.ShippingDays));
                        showShippingInDeliveryOptions = allowShippingTill <= model.ScheduleDate.Date;
                        pickuppharase = delvroptions.PickupText;
                        shippingDays  = delvroptions.ShippingDays;
                    }
                }
            }

            Student previous = new Student();

            if (model.iid > 0)
            {
                previous = db.Student.Where(x => x.StudentID == model.iid).FirstOrDefault();
            }


            //Attention: Answer Array needs to be adjust in student object

            Student student = (from schedule in db.ScheduleClass
                               join course in db.CourseType on schedule.CourseID equals course.CourseTypeID
                               join location in db.Location on schedule.LocationID equals location.LocationID into ps
                               from location in ps.DefaultIfEmpty()
                               where schedule.ClassID == model.ClassID
                               select new { ClassID = schedule.ClassID, CourseName = course.CourseName, Location = location == null ? "" :  location.Name, ClassPrice = schedule.Price, ScheduleDate = schedule.ScheduleDate, StartTime = schedule.StartTime, EndTime = schedule.EndTime, SelectedOptions = options, OptionsPrice = optionsprice, ShowDeliveryOptions = showdeliveryoptions, showShippingInDeliveryOptions = showShippingInDeliveryOptions, ShippingDays = shippingDays, PickupPharase = pickuppharase, ExtraClasstimes = schedule.ExtraClassTimes, FirstName = previous.FirstName, LastName = previous.LastName, Email = previous.Email, PrimaryPhone = previous.PrimaryPhone, AlternatePhone = previous.AlternatePhone, MailingAddress1 = previous.MailingAddress1, MailingAddress2 = previous.MailingAddress2, MailingCity = previous.MailingCity, MailingState = previous.MailingState, MailingZip = previous.MailingZip, IsBillingSameAsMailing = previous.IsBillingSameAsMailing, PayOnArrival = schedule.IsAllowedRegistrationWithoutPayment, ShippingCost = course.ShippingPrice, PaypalEmail = paypalemail, CourseType = course.Type, isPromptCertification = course.CourseOptions_PromptForCertificationDuringRegistration, KeycodeBankID = course.KeycodeBankID, locationID = location.LocationID })
                              .AsEnumerable().Select(x => new Student {
                ClassID = x.ClassID, CourseName = x.CourseName, Location = x.Location, ClassPrice = x.ClassPrice, ScheduleDate = x.ScheduleDate, StartTime = x.StartTime, EndTime = x.EndTime, SelectedOptions = options, OptionsPrice = optionsprice, ShowDeliveryOptions = x.ShowDeliveryOptions, showShippingInDeliveryOptions = x.showShippingInDeliveryOptions, ShippingDays = x.ShippingDays, PickupPharase = x.PickupPharase, ExtraClassTimes = x.ExtraClasstimes, FirstName = x.FirstName, LastName = x.LastName, Email = x.Email, PrimaryPhone = x.PrimaryPhone, AlternatePhone = x.AlternatePhone, MailingAddress1 = x.MailingAddress1, MailingAddress2 = x.MailingAddress2, MailingCity = x.MailingCity, MailingState = x.MailingState, MailingZip = x.MailingZip, IsBillingSameAsMailing = x.IsBillingSameAsMailing, PayOnArrival = x.PayOnArrival, ShippingCostMaterial = x.ShippingCost, PaypalEmail = x.PaypalEmail, CourseType = x.CourseType, IsPromptCertification = x.isPromptCertification, KeycodeBankID = x.KeycodeBankID, LocationID = x.locationID
            }).FirstOrDefault();

            return(View(student));
        }
 public async Task <IActionResult> Details(int?id)
 {
     if (id.HasValue)
     {
         return(View(await ClassDetailViewModel.FromIDAsync(id.Value, _context)));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
예제 #5
0
        public ActionResult ClassDetail(int id, int iid = 0)
        {
            Context db = new Context();
            ClassDetailViewModel model = (from schedule in db.ScheduleClass
                                          join course in db.CourseType on schedule.CourseID equals course.CourseTypeID
                                          join location in db.Location on schedule.LocationID equals location.LocationID into ps
                                          from location in ps.DefaultIfEmpty()
                                          where schedule.ClassID == id
                                          select new ClassDetailViewModel {
                ClassID = schedule.ClassID, CourseImage = course.Image, CourseName = course.CourseName, CourseDescription = course.Description, Location = location == null ? "" : location.Name, ClassPrice = schedule.Price, ScheduleDate = schedule.ScheduleDate, StartTime = schedule.StartTime, EndTime = schedule.EndTime, CourseAddOns = course.AddOns, ExtraClasses = schedule.ExtraClassTimes
            }).FirstOrDefault();

            ViewBag.iid = iid;
            return(View(model));
        }
예제 #6
0
 /// <summary>
 /// Lädt die Daten vom Server, wenn die Seite angezeigt wird. Das ist auch beim
 /// Zurücknavigieren der Fall. Wenn das zu lange dauert, muss im RestService ein Cache
 /// einprogrammiert werden.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void ContentPage_Appearing(object sender, EventArgs e)
 {
     try
     {
         ClassDetailViewModel vm = BindingContext as ClassDetailViewModel;
         await vm?.LoadClassDetails();
     }
     // Diese Fehler dürften hier gar nicht mehr auftreten, da das Laden der Seite nur mit
     // gültiger Rolle zu ermöglichen ist.
     catch (ServiceException err) when(err.HttpStatusCode == (int)HttpStatusCode.Unauthorized)
     {
         await App.Current.MainPage.DisplayAlert("Fehler", "Nicht angemeldet", "OK");
     }
     catch (ServiceException err) when(err.HttpStatusCode == (int)HttpStatusCode.Forbidden)
     {
         await App.Current.MainPage.DisplayAlert("Fehler", "Keine Berechtigung", "OK");
     }
 }
예제 #7
0
 /// <summary>
 /// Konstruktor, der die Page und das ViewModel mit der übergebenen Klasse initialisiert.
 /// </summary>
 /// <param name="currentId">ID der Klasse, dessen Details angezeigt werden sollen.</param>
 public ClassDetailPage(string currentId) : this()
 {
     // Das Viewmodel mit der anzuzeigenden Klasse initialisieren.
     BindingContext = new ClassDetailViewModel(currentId);
     Title          = currentId;
 }
 /// <summary>
 /// Lädt die Daten vom Server, wenn die Seite angezeigt wird. Das ist auch beim
 /// Zurücknavigieren der Fall. Wenn das zu lange dauert, muss im RestService ein Cache
 /// einprogrammiert werden.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void ContentPage_Appearing(object sender, EventArgs e)
 {
     ClassDetailViewModel vm = BindingContext as ClassDetailViewModel;
     await vm.LoadClassDetails();
 }