public ActionResult UserEdit([Bind(Include = "UserID,UserName,Password,FirstName,LastName,Company,CompanyLogo,Email")] User user)
        {
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0)
                {
                    //Guid nesnesini benzersiz dosya adı oluşturmak için tanımladık ve Replace ile aradaki “-” işaretini atıp yan yana yazma işlemi yaptık.
                    string DosyaAdi = Guid.NewGuid().ToString().Replace("-", "");
                    //Kaydetceğimiz resmin uzantısını aldık.
                    string uzanti     = System.IO.Path.GetExtension(Request.Files[0].FileName);
                    string TamYolYeri = "/Images/" + DosyaAdi + uzanti;
                    //Eklediğimiz Resni Server.MapPath methodu ile Dosya Adıyla birlikte kaydettik.
                    Request.Files[0].SaveAs(Server.MapPath(TamYolYeri));
                    //Ve veritabanına kayıt için dosya adımızı değişkene aktarıyoruz.
                    user.CompanyLogo = DosyaAdi + uzanti;
                }
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Profil", "Home"));
            }

            return(View(user));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "NotificationID,Notification_Description,Count,Notification_Date,FKUserId")] Notification notification)
 {
     if (ModelState.IsValid)
     {
         db.Entry(notification).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FKUserId = new SelectList(db.User, "UserID", "UserName", notification.FKUserId);
     return(View(notification));
 }
 public ActionResult Edit([Bind(Include = "NoteID,NoteHeader,NoteDescription,CreatedDate,FkPieceID,FkSubPieceID,FkUserID")] Note note)
 {
     if (ModelState.IsValid)
     {
         db.Entry(note).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FkPieceID    = new SelectList(db.Piece, "PieceID", "PieceName", note.FkPieceID);
     ViewBag.FkSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName", note.FkSubPieceID);
     ViewBag.FkUserID     = new SelectList(db.User, "UserID", "UserName", note.FkUserID);
     return(View(note));
 }
Example #4
0
        public ActionResult Edit([Bind(Include = "SubPieceID,SubPieceName,ToolLife,Now,FKPieceID,FKUserID,Type")] SubPiece subPiece)
        {
            ViewBag.UserID = Session["UserID"];
            int ID = Convert.ToInt32(Session["UserID"]);

            if (ModelState.IsValid)
            {
                subPiece.FKUserID        = ID;
                db.Entry(subPiece).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.FKPieceID = new SelectList(db.Piece, "PieceID", "PieceName", subPiece.FKPieceID);
            ViewBag.FKUserID  = new SelectList(db.User, "UserID", "UserName", subPiece.FKUserID);
            return(View(subPiece));
        }
        public ActionResult Edit([Bind(Include = "DetailID,PieceCount,CreatedDate,FKSubPieceID,FKUserID")] Detail detail)
        {
            ViewBag.UserID = Session["UserID"];
            int ID = Convert.ToInt32(Session["UserID"]);

            if (ModelState.IsValid)
            {
                detail.FKUserID        = ID;
                db.Entry(detail).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.FKSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName", detail.FKSubPieceID);
            ViewBag.FKUserID     = new SelectList(db.User, "UserID", "UserName", detail.FKUserID);
            return(View(detail));
        }
        public ActionResult Edit([Bind(Include = "PieceID,PieceName,FKUserID,CreatedDate,Adet")] Piece piece)
        {
            ViewBag.UserID = Session["UserID"];
            int ID = Convert.ToInt32(Session["UserID"]);
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            if (ModelState.IsValid)
            {
                piece.FKUserID        = ID;
                piece.Adet            = 0;
                piece.CreatedDate     = DateTime.Now;
                db.Entry(piece).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Indexx"));
            }
            ViewBag.FKUserID = new SelectList(db.User, "UserID", "UserName", piece.FKUserID);
            return(View(piece));
        }