コード例 #1
0
        public ActionResult Index(string imageData, string inText)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            UserTitles           ut = new UserTitles();

            ut.Name  = User.Identity.Name;
            ut.Title = inText;
            db.UserTitles.Add(ut);
            db.SaveChanges();
            //string fileNameWitPath = @"D:\" + DateTime.Now.ToString().Replace("/", "-").Replace(" ", "- ").Replace(":", "") + ".png";
            string fileNameWitPath = @"C:\Uploads\" + User.Identity.Name + @"\" + inText + ".png";

            if (!Directory.Exists(@"C:\Uploads"))
            {
                Directory.CreateDirectory(@"C:\Uploads");
            }
            if (!Directory.Exists(@"C:\Uploads\" + User.Identity.Name))
            {
                Directory.CreateDirectory(@"C:\Uploads\" + User.Identity.Name);
            }
            using (FileStream fs = new FileStream(fileNameWitPath, FileMode.Create))
            {
                using (BinaryWriter bw = new BinaryWriter(fs))

                {
                    byte[] data = Convert.FromBase64String(imageData);
                    bw.Write(data);
                    bw.Close();
                }
            }
            return(View());
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            UserTitles userTitles = db.UserTitles.Find(id);

            db.UserTitles.Remove(userTitles);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public static UserTitlesWM MaptoWM(UserTitles entity)
 {
     return(new UserTitlesWM()
     {
         UserTitleID = entity.UserTitleID,
         UserTitleName = entity.UserTitleName
     });
 }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,Name,Title,Type,Description")] UserTitles userTitles)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userTitles).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userTitles));
 }
コード例 #5
0
        public ActionResult Create([Bind(Include = "Id,Name,Title,Type,Description")] UserTitles userTitles)
        {
            if (ModelState.IsValid)
            {
                db.UserTitles.Add(userTitles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userTitles));
        }
コード例 #6
0
 public void DeleteUserTitle(UserTitles entity)
 {
     try
     {
         _uow.UserTitles.Remove(entity);
         _uow.Complete();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
コード例 #7
0
 public UserTitles GetUserTitle(int id)
 {
     try
     {
         UserTitles userTitle = _uow.UserTitles.Get(id);
         _uow.Complete();
         return(userTitle);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
コード例 #8
0
        // GET: UserProfile/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserTitles userTitles = db.UserTitles.Find(id);

            if (userTitles == null)
            {
                return(HttpNotFound());
            }
            return(View(userTitles));
        }