public IHttpActionResult Putwork_group_tags(int id, work_group_tags work_group_tags)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != work_group_tags.work_group_id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!work_group_tagsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult ArchiveGroup(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.archive_work_group(id);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!work_groupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public IHttpActionResult PutCourse_Members(Course_Members course_Members)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Course_MembersExists(course_Members.Course_id, course_Members.Member_id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult Putinst_previous_courses(int id, inst_previous_courses inst_previous_courses)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!inst_previous_coursesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #5
0
        public async Task <IHttpActionResult> likeCourse(like like)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            like.liked_type = "course";
            db.likes.Add(like);
            db.SaveChanges();


            var new_notifi = new cls_notifi
            {
                source_name  = "course",
                source_id    = like.liked_id.ToString(),
                image        = db.AspNetUsers.FirstOrDefault(x => x.Id == like.user_id).Photo,//"no image",
                body_English = db.AspNetUsers.FirstOrDefault(x => x.Id == like.user_id).UserName + " likes your course " + db.courses.FirstOrDefault(x => x.id == like.liked_id).name,
                body_Arabic  = "اعجب " + db.AspNetUsers.FirstOrDefault(x => x.Id == like.user_id).UserName + " بانشائك كورس " + db.courses.FirstOrDefault(x => x.id == like.liked_id).name,
                timestamp    = DateTime.Now,
                readed       = false
            };
            var course_admin = db.courses.FirstOrDefault(x => x.id == like.liked_id).instructor;

            await Push(new_notifi, "notifications/" + course_admin.ToString() + "/" + DateTime.UtcNow.ToString("dd-MM-yyyy"));

            PushNotifi(db.AspNetUsers.FirstOrDefault(x => x.Id == course_admin).DeviceToken, "More Likes", new_notifi.body_English, "course", like.liked_id.ToString());


            return(CreatedAtRoute("DefaultApi", new { id = like.id }, like));
        }
예제 #6
0
        public IHttpActionResult Puttag(int id, tag tag)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tagExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutRoom_Members(int id, Room_Members room_Members)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != room_Members.Room_id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Room_MembersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #8
0
        public IHttpActionResult PutSecurityInfo(string id, security_info info)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            db.add_security_info(info.Id, info.GuaranteeDecument, info.IdCard, info.Residence, info.Photograph);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AspNetUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #9
0
        // GET: mvcUsers
        public ActionResult Accept_instructor(string id)
        {
            AspNetUser aspNetUser = db.AspNetUsers.Find(id);

            aspNetUser.IsInstructor    = true;
            db.Entry(aspNetUser).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "id,name,about,creating_date,place,trange,availlable,way_to_apply,notes,admin,category,video,Archived")] work_group work_group)
        {
            if (ModelState.IsValid)
            {
                db.work_group.Add(work_group);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(work_group));
        }
예제 #11
0
        public ActionResult Create([Bind(Include = "id,name,about,creating_date,place,trange,cost,way_to_pay,allow_buying,availlable,way_to_apply,notes,instructor,video,category,Archived")] course course)
        {
            if (ModelState.IsValid)
            {
                db.courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
예제 #12
0
        public ActionResult Create([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName,Country,State,Gender,Photo,Apout,AnotherAccount,IsInstructor,GuaranteeDecument,IdCard,Residence,Photograph")] AspNetUser aspNetUser)
        {
            if (ModelState.IsValid)
            {
                db.AspNetUsers.Add(aspNetUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetUser));
        }
예제 #13
0
        public IHttpActionResult uploadVideo(int course_id)
        {
            var file = HttpContext.Current.Request.Files.Count > 0 ?
                       HttpContext.Current.Request.Files[0] : null;

            if (file != null && file.ContentLength > 0)
            {
                //var fileName = Path.GetFileName(file.FileName);
                string filename  = Path.GetFileNameWithoutExtension(file.FileName);
                string extention = Path.GetExtension(file.FileName);
                filename = filename + DateTime.Now.ToString("yymmddssfff") + extention;
                var path = Path.Combine(
                    HttpContext.Current.Server.MapPath("~/Content/uploads/videos/"),
                    filename
                    );
                var courseTo_edit = db.courses.FirstOrDefault(x => x.id == course_id);
                courseTo_edit.video           = "~/Content/uploads/videos/" + filename;
                db.Entry(courseTo_edit).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (Exception)
                {
                }
                file.SaveAs(path);
            }
            var group_to_return = db.courses.Where(x => x.id == course_id).Select(x => new { x.id, x.name, x.video });

            return(Ok(group_to_return));
        }
예제 #14
0
        public IHttpActionResult Editcertificate(certificate certificate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var file = HttpContext.Current.Request.Files.Count > 0 ?
                       HttpContext.Current.Request.Files[0] : null;

            if (file != null && file.ContentLength > 0)
            {
                //var fileName = Path.GetFileName(file.FileName);
                string filename  = Path.GetFileNameWithoutExtension(file.FileName);
                string extention = Path.GetExtension(file.FileName);
                filename = filename + DateTime.Now.ToString("yymmddssfff") + extention;
                var path = Path.Combine(
                    HttpContext.Current.Server.MapPath("~/Content/uploads/images/"),
                    filename
                    );
                certificate.image = "~/Content/uploads/images/" + filename;

                file.SaveAs(path);
            }



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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!certificateExists(certificate.id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #15
0
        public IHttpActionResult finishCourseForOne(int Course_id, string memper_id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.finish_course_for_one_member(memper_id, Course_id);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!courseExists(Course_id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #16
0
        public IHttpActionResult Deletefriend(string User1, string User2)
        {
            friend friend1 = db.friends.Find(User1, User2);
            friend friend2 = db.friends.Find(User2, User1);

            if (friend1 == null && friend2 == null)
            {
                return(NotFound());
            }

            //       db.friends.Remove(friend);

            db.remove_friend_or_frequest(User1, User2);
            db.SaveChanges();
            if (friend1 == null)
            {
                return(Ok(friend2));
            }
            else
            {
                return(Ok(friend1));
            }
        }
예제 #17
0
        public IHttpActionResult PostNewtags(cls_tag tags)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            List <int> ids = new List <int>();

            foreach (string item in tags.tag_names)
            {
                if (!db.tags.Any(x => x.tag1 == item))
                {
                    tag tag_to_add = new tag();
                    tag_to_add.tag1 = item;
                    db.tags.Add(tag_to_add);
                    db.SaveChanges();
                    ids.Add(db.tags.OrderByDescending(x => x.id).FirstOrDefault().id);
                }
                else
                {
                    ids.Add(db.tags.FirstOrDefault(x => x.tag1 == item).id);
                }
            }
            if (tags.Type == "course")
            {
                foreach (int item in ids)
                {
                    course_tags t = new course_tags
                    {
                        course_id = tags.TypeId,
                        tag_id    = item
                    };
                    db.course_tags.Add(t);
                    db.SaveChanges();
                }
            }
            else if (tags.Type == "group")
            {
                foreach (int item in ids)
                {
                    work_group_tags t = new work_group_tags
                    {
                        work_group_id = tags.TypeId,
                        tag_id        = item
                    };
                    db.work_group_tags.Add(t);
                    db.SaveChanges();
                }
            }


            return(Ok(tags));
        }
예제 #18
0
        public IHttpActionResult SetDeviceToken(string userId, string DeviceToken)
        {
            var userTo_edit = db.AspNetUsers.FirstOrDefault(x => x.Id == userId);

            userTo_edit.DeviceToken     = DeviceToken;
            db.Entry(userTo_edit).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
            }

            var userToReturn = db.AspNetUsers.Where(x => x.Id == userId).Select(x => new cls_user
            {
                Id                   = x.Id,
                UserName             = x.UserName,
                State                = x.State,
                Residence            = x.Residence,
                Photograph           = x.Photograph,
                Photo                = x.Photo,
                PhoneNumberConfirmed = x.PhoneNumberConfirmed,
                PhoneNumber          = x.PhoneNumber,
                IsInstructor         = x.IsInstructor,
                IdCard               = x.IdCard,
                GuaranteeDecument    = x.GuaranteeDecument,
                Gender               = x.Gender,
                EmailConfirmed       = x.EmailConfirmed,
                Email                = x.Email,
                Country              = x.Country,
                Apout                = x.Apout,
                AnotherAccount       = x.AnotherAccount,
                IdCardBack           = x.IdCardBack,
                facebookAccount      = x.facebookAccount,
                twitterAccount       = x.twitterAccount,
                jobTitle             = x.jobTitle
            });

            return(Ok(userToReturn));
        }
예제 #19
0
 public TEntity Add(TEntity entity)
 {
     _set.Add(entity);
     return(_ctx.SaveChanges() > 0 ? entity : null);
 }
예제 #20
0
 public bool save()
 {
     return(ctx.SaveChanges() > 0);
 }