Пример #1
0
        public Webinar CreateWebinar(CreateWebinarRequest request)
        {
            int IdUser = getIdUserByLogin(request.Login);

            if (_context.Webinars.Where(x => x.Code == request.Code).Any())
            {
                throw new CodeOccupiedException("");
            }
            if (request.FinishTime < request.StartTime)
            {
                throw new FinishBeforeStartException("");
            }

            Webinar webinar;

            _context.Webinars.Add(webinar = new Webinar
            {
                Code      = request.Code,
                Topic     = request.Topic,
                Date      = request.Date.GetValueOrDefault(),
                StartTime = request.StartTime.GetValueOrDefault(),
                EndTime   = request.FinishTime.GetValueOrDefault(),
                IdUser    = IdUser
            });
            _context.SaveChanges();
            return(webinar);
        }
Пример #2
0
        public async Task <IHttpActionResult> PutWebinar(int id, Webinar webinar)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != webinar.Id)
            {
                return(BadRequest());
            }

            db.Entry(webinar).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WebinarExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public async Task <HttpStatusCode> EditWebinar(Webinar webinar)
        {
            WebinarsController webinarsController = new WebinarsController();
            var status = await webinarsController.UpdateWebinarAsync(webinar);

            return(status);
        }
Пример #4
0
 public Webinar Update(Webinar webinar)
 => Execute(context =>
 {
     var result = context.Webinars.Update(webinar);
     context.SaveChanges();
     return(result.Entity);
 });
Пример #5
0
        public async Task <IActionResult> Edit(int id, [Bind("EventID,Title,Description,StartDateTime,CourseID")] Webinar webinar)
        {
            if (id != webinar.EventID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(webinar);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WebinarExists(webinar.EventID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"] = new SelectList(_context.Courses, "CourseID", "Title", webinar.CourseID);
            return(View(webinar));
        }
Пример #6
0
 public Webinar Create(Webinar webinar)
 => Execute(context =>
 {
     context.Webinars.Add(webinar);
     context.SaveChanges();
     return(webinar);
 });
Пример #7
0
        public IActionResult Put(int id, [FromBody] Webinar webinar)
        {
            webinar.Id = id;
            var updateWebinar = webinarBL.Update(webinar);

            return(Ok(updateWebinar));
        }
Пример #8
0
        public void EditWebinar(EditWebinarRequest request, string code)
        {
            if (!WebinarExists(code))
            {
                throw new WebinarNotExistException("");
            }
            Webinar webinar = _context.Webinars.Where(x => x.Code == code).FirstOrDefault();

            if (webinar.Date < DateTime.Now)
            {
                throw new DoneWebinarException("");
            }
            if (webinar.IdUser != getIdUserByLogin(request.Login))
            {
                throw new WebinarNotHostedByGivenUserException("");
            }
            if (request.FinishTime < request.StartTime)
            {
                throw new FinishBeforeStartException("");
            }

            webinar.Topic     = request.Topic;
            webinar.Date      = request.Date.GetValueOrDefault();
            webinar.StartTime = request.StartTime.GetValueOrDefault();
            webinar.EndTime   = request.FinishTime.GetValueOrDefault();
            _context.SaveChanges();
        }
Пример #9
0
        /// <summary>
        /// Gets a specific webinar based on its key
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="organizerKey"></param>
        /// <param name="webinarKey"></param>
        /// <returns></returns>
        public Webinar GetWebinar(string accessToken, string organizerKey, string webinarKey)
        {
            var webinarRestUri  = string.Format(WebinarUri, organizerKey, webinarKey);
            var webinarResponse = CallGoToWebinarApi <WebinarResponse>(accessToken, webinarRestUri);
            var webinar         = new Webinar(webinarResponse);

            return(webinar);
        }
Пример #10
0
 private void ListWebinars_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count == 0)
     {
         return;
     }
     selectedWebinar = (Webinar)e.AddedItems[0];
 }
Пример #11
0
        public async Task <HttpStatusCode> UpdateWebinarAsync(Webinar webinar)
        {
            HttpResponseMessage response = await PublicResources.client.PutAsJsonAsync(
                $"api/WebinarsAPI/{webinar.Id}", webinar);

            response.EnsureSuccessStatusCode();
            return(response.StatusCode);
        }
Пример #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            Webinar webinar = db.Tb_Webinar.Find(id);

            db.Tb_Webinar.Remove(webinar);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public WebinarStatistic(Webinar webinar)
        {
            InitializeComponent();

            this.webin = webinar;
            contentContainer.Navigate(new Statistics(webinar));

            slideRight();
        }
Пример #14
0
 public void Delete(int id)
 => Execute(context =>
 {
     var webinar = new Webinar {
         Id = id
     };
     context.Webinars.Remove(webinar);
     context.SaveChanges();
 });
Пример #15
0
        private void UpdateEnrollDeadline(Webinar webinar)
        {
            var earliestStart = webinarBL.GetEarliestSessionStart(webinar.Id);

            if (earliestStart.HasValue)
            {
                webinar.EnrollDeadline = earliestStart.Value.AddHours(-1).AddMinutes(-1);
            }
        }
Пример #16
0
 public ActionResult Edit([Bind(Include = "WebinarId,WebinarTheme,WebinarInitialDate,WebinarEndDate,UserCount,available")] Webinar webinar)
 {
     if (ModelState.IsValid)
     {
         db.Entry(webinar).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(webinar));
 }
Пример #17
0
        public ActionResult Create([Bind(Include = "WebinarId,WebinarTheme,WebinarInitialDate,WebinarEndDate,available,congressId")] Webinar webinar)
        {
            if (ModelState.IsValid)
            {
                db.Tb_Webinar.Add(webinar);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(webinar));
        }
Пример #18
0
        public async Task <IHttpActionResult> GetWebinar(int id)
        {
            Webinar webinar = await db.Webinars.FindAsync(id);

            if (webinar == null)
            {
                return(NotFound());
            }

            return(Ok(webinar));
        }
Пример #19
0
 public ActionResult Edit([Bind(Include = "WebinarId,WebinarTheme,WebinarBannerPrincipal,WebinarImagen,WebinarInitialDate,WebinarEndDate,available,CongressId")] Webinar webinar)
 {
     if (ModelState.IsValid)
     {
         db.Entry(webinar).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CongressId = new SelectList(db.Tb_Congress, "CongressId", "CongressName", webinar.CongressId);
     return(View(webinar));
 }
Пример #20
0
        public void OpenWebinarStatics(Webinar webinar)
        {
            Webinar webinar_staistic = webinar;

            try
            {
                webinar_staistic = WebinarApiInstance.GetWebinarStatic(token, webinar.Id);
            } catch (Exception exc) { }

            ((NavigationWindow)Application.Current.MainWindow).Navigate(new WebinarStatistic(webinar_staistic));
        }
Пример #21
0
        public async Task <IActionResult> Create([Bind("EventID,Title,Description,StartDateTime,CourseID")] Webinar webinar)
        {
            if (ModelState.IsValid)
            {
                _context.Add(webinar);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"] = new SelectList(_context.Courses, "CourseID", "Title", webinar.CourseID);
            return(View(webinar));
        }
Пример #22
0
        public async Task <IHttpActionResult> PostWebinar(Webinar webinar)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Webinars.Add(webinar);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = webinar.Id }, webinar));
        }
        public WebinarInfo(Webinar webinar)
        {
            InitializeComponent();

            switch (webinar.TypeLesson)
            {
            case LessonType.Practic:
                Type.Text = "Практическая работа";
                break;

            case LessonType.Lecture:
                Type.Text = "Лекция";
                break;

            case LessonType.Lab:
                Type.Text = "Лабораторная работа";
                break;
            }
            Discipline.Text = webinar.Discipline;
            if (webinar.Teacher != null)
            {
                Teacher.Text = webinar.Teacher.LastName + " " + webinar.Teacher.FirstName[0] + ".";
            }
            if (webinar.StartTime.HasValue)
            {
                StartTimeDate.Text = webinar.StartTime.Value.Date.ToString("dd.MM.yyyy");
                StartTimeTime.Text = webinar.StartTime.Value.ToString("HH:mm");
            }

            if (webinar.Groups != null)
            {
                foreach (Group group in webinar.Groups)
                {
                    TextBlock tb = new TextBlock()
                    {
                        FontSize   = 18,
                        Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2b2b2b")),
                        Text       = group.Name
                    };
                    GroupsContainer.Children.Add(tb);
                }
            }

            if (webinar.Files != null)
            {
                foreach (ModelFile file in webinar.Files)
                {
                    FileLine fl = new FileLine(file.Name, file.Link);
                    FilesList.Children.Add(fl);
                }
            }
        }
Пример #24
0
        // GET: Webinars/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Webinar webinar = db.Tb_Webinar.Find(id);

            if (webinar == null)
            {
                return(HttpNotFound());
            }
            return(View(webinar));
        }
Пример #25
0
        public async Task <IHttpActionResult> DeleteWebinar(int id)
        {
            Webinar webinar = await db.Webinars.FindAsync(id);

            if (webinar == null)
            {
                return(NotFound());
            }

            db.Webinars.Remove(webinar);
            await db.SaveChangesAsync();

            return(Ok(webinar));
        }
Пример #26
0
        public ActionResult CreateWebinarViewModel(CreateWebinar cw)
        {
            var webinar = new Webinar
            {
                WebinarTheme       = cw.WebinarTheme,
                WebinarInitialDate = cw.WebinarInitialDate,
                WebinarEndDate     = cw.WebinarEndDate,
                CongressId         = cw.congressId
            };

            if (ModelState.IsValid)
            {
            }
            return(View());
        }
Пример #27
0
        // GET: Webinars/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Webinar webinar = db.Tb_Webinar.Find(id);

            if (webinar == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CongressId = new SelectList(db.Tb_Congress, "CongressId", "CongressName", webinar.CongressId);
            return(View(webinar));
        }
Пример #28
0
        private void background_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            var  UserApiInstance = new UserApi();
            User localUser       = UserApiInstance.GetUserInfo(Application.Current.Resources["token"].ToString());

            if (localUser.UserStatus != UserStatus.Student)
            {
                var     WebinarApiInstance = new WebinApi();
                Webinar statisWebinar      = webinar;
                try
                {
                    statisWebinar = WebinarApiInstance.GetWebinarStatic(Application.Current.Resources["token"].ToString(), webinar.Id);
                } catch (Exception ex) { }
                ((Week)Application.Current.MainWindow.Content).OpenWebinarStatics(statisWebinar);
            }
        }
Пример #29
0
        public Webinar CreateWithUserWebinar(Webinar webinar, int userId)
        => Execute(context =>
        {
            context.Webinars.Add(webinar);
            context.SaveChanges();

            context.UserWebinars.Add(new UserWebinar
            {
                UserId     = userId,
                EnrollDate = DateTime.UtcNow,
                WebinarId  = webinar.Id,
                AccessType = Domain.Enums.CourseAccessTypeEnum.Teacher
            });
            context.SaveChanges();
            return(webinar);
        });
Пример #30
0
        public void DeleteWebinar(DeleteWebinarRequest request, string code)
        {
            if (!WebinarExists(code))
            {
                throw new WebinarNotExistException("");
            }
            Webinar webinar = _context.Webinars.Where(x => x.Code == code).FirstOrDefault();

            if (webinar.Date < DateTime.Now)
            {
                throw new DoneWebinarException("");
            }
            if (webinar.IdUser != getIdUserByLogin(request.Login))
            {
                throw new WebinarNotHostedByGivenUserException("");
            }
            _context.Webinars.Remove(webinar);
            _context.SaveChanges();
        }