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()); }
public ActionResult DeleteConfirmed(int id) { UserTitles userTitles = db.UserTitles.Find(id); db.UserTitles.Remove(userTitles); db.SaveChanges(); return(RedirectToAction("Index")); }
public static UserTitlesWM MaptoWM(UserTitles entity) { return(new UserTitlesWM() { UserTitleID = entity.UserTitleID, UserTitleName = entity.UserTitleName }); }
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)); }
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)); }
public void DeleteUserTitle(UserTitles entity) { try { _uow.UserTitles.Remove(entity); _uow.Complete(); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public UserTitles GetUserTitle(int id) { try { UserTitles userTitle = _uow.UserTitles.Get(id); _uow.Complete(); return(userTitle); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
// 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)); }