コード例 #1
0
 public ActionResult Edit([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.Entry(aspNetUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aspNetUser));
 }
コード例 #2
0
 public ActionResult Edit([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.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(course));
 }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
0
ファイル: Repository.cs プロジェクト: ragaey90/live.courses
 public bool Update(TEntity entity)
 {
     _set.Attach(entity);
     _ctx.Entry(entity).State = EntityState.Modified;
     return(_ctx.SaveChanges() > 0);
 }