Ejemplo n.º 1
0
        public void Edit(PocoCourse course)
        {
            if (course.InstructorsId.Count > 0)
            {
                var obj = ctx.Instructor_Course.Find(course.Id);
                foreach (int id in course.InstructorsId)
                {
                    Instructor_Course ic = new Instructor_Course()
                    {
                        id = obj.id,
                        fk_instructorid = id,
                    };

                    ctx.Instructor_Course.Attach(ic);
                    ctx.Entry(ic).State = EntityState.Modified;
                    ctx.SaveChanges();
                }
            }
            if (course.StudentsId.Count > 0)
            {
                var obj = ctx.Student_Course.Find(course.Id);
                foreach (int id in course.StudentsId)
                {
                    Student_Course sc = new Student_Course()
                    {
                        id           = obj.id,
                        fk_studentid = id,
                        fk_courseid  = course.Id
                    };
                    ctx.Entry(sc).State = EntityState.Modified;

                    ctx.SaveChanges();
                }
            }
        }
Ejemplo n.º 2
0
 public void Add(Course newCourse, PocoCourse course)
 {
     if (course.InstructorsId != null)
     {
         foreach (int id in course.InstructorsId)
         {
             Instructor_Course ic = new Instructor_Course()
             {
                 fk_instructorid = id,
                 fk_courseid     = newCourse.id
             };
             ctx.Instructor_Course.Add(ic);
             ctx.SaveChanges();
         }
     }
     if (course.StudentsId != null)
     {
         foreach (int id in course.StudentsId)
         {
             Student_Course sc = new Student_Course()
             {
                 fk_studentid = id,
                 fk_courseid  = newCourse.id
             };
             ctx.Student_Course.Add(sc);
             ctx.SaveChanges();
         }
     }
 }
Ejemplo n.º 3
0
        public IHttpActionResult PostCourse(PocoCourse course)
        {
            if (course.InstructorsId != null || course.StudentsId != null)
            {
                Course newCourse = new Course()
                {
                    code      = course.Code,
                    name      = course.Name,
                    hours     = course.Hours,
                    isDeleted = false,
                };
                Course x = db.Course.Add(newCourse);
                db.SaveChanges();
                ctx.Add(x, course);

                return(CreatedAtRoute("DefaultApi", new { id = x.id }, newCourse));
            }
            else
            {
                Course newCourse = new Course()
                {
                    code      = course.Code,
                    name      = course.Name,
                    hours     = course.Hours,
                    isDeleted = false,
                };
                Course x = db.Course.Add(newCourse);
                db.SaveChanges();
                ctx.Add(x, course);

                return(CreatedAtRoute("DefaultApi", new { id = x.id }, newCourse));
            }
        }
Ejemplo n.º 4
0
        public List <notification> getData(out DateTime lastRefreshed)
        {
            var client  = new RestClient("https://api.rootnet.in/covid19-in/notifications");
            var request = new RestRequest(Method.GET);

            request.AddHeader("postman-token", "efd6234b-3e85-42f4-6e52-67c80c45f567");
            request.AddHeader("cache-control", "no-cache");
            IRestResponse response = client.Execute(request);
            PocoCourse    items    = JsonConvert.DeserializeObject <PocoCourse>(response.Content);

            lastRefreshed = items.lastRefreshed;
            return(items.data.notifications.Where(x => x.title.Contains(".2020")).ToList());
        }
Ejemplo n.º 5
0
        public List <regional> getData(out string number, out string numbertollfree, out string email, out string facebook)
        {
            var client  = new RestClient("https://api.rootnet.in/covid19-in/contacts");
            var request = new RestRequest(Method.GET);

            request.AddHeader("postman-token", "efd6234b-3e85-42f4-6e52-67c80c45f567");
            request.AddHeader("cache-control", "no-cache");
            IRestResponse response = client.Execute(request);
            PocoCourse    items    = JsonConvert.DeserializeObject <PocoCourse>(response.Content);

            number         = items.data.contacts.primary.number;
            numbertollfree = items.data.contacts.primary.numbertollfree;
            email          = items.data.contacts.primary.email;
            facebook       = items.data.contacts.primary.facebook;
            return(items.data.contacts.regional.OrderBy(x => x.loc).ToList());
        }
Ejemplo n.º 6
0
        public List <regional> getData(out int total, out float death, out float discharged, out DateTime lastRefreshed)
        {
            var client  = new RestClient("https://api.rootnet.in/covid19-in/stats/latest");
            var request = new RestRequest(Method.GET);

            request.AddHeader("postman-token", "efd6234b-3e85-42f4-6e52-67c80c45f567");
            request.AddHeader("cache-control", "no-cache");
            IRestResponse response = client.Execute(request);
            PocoCourse    items    = JsonConvert.DeserializeObject <PocoCourse>(response.Content);

            total         = items.data.summary.total;
            death         = items.data.summary.deaths;
            discharged    = items.data.summary.discharged;
            lastRefreshed = items.lastRefreshed;
            return(items.data.regional.OrderByDescending(x => x.totalConfirmed).ToList());
        }