public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public ActionResult UpdateProfile(ProfileModel modeli) { try { if (modeli.profilePic != null) { if (modeli.profilePic.ContentLength > 0) { string fileExtension = System.IO.Path.GetExtension(modeli.profilePic.FileName); if (fileExtension == ".png") { string fileLocation = Server.MapPath("~/Img/ProfilePics/") + Session["perdoruesiID"].ToString() + fileExtension; if (System.IO.File.Exists(fileLocation)) { try { System.IO.File.Delete(fileLocation); } catch { TempData["Alert"] = "Mbyll imazhin!"; } } modeli.profilePic.SaveAs(fileLocation); } else { TempData["Error"] = "Fajlli nuk eshte .png!"; } } } var perdoruesi = db.tblPerdoruesit.Find(Session["perdoruesiID"]); perdoruesi.Fjalkalimi = Krijo_DB_Fjalekalimin(_bytSalt, modeli.Fjalekalimi); db.Entry(perdoruesi).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); TempData["Alert"] = "Profili u ndryshua me sukses!"; } catch (Exception ex) { TempData["Error"] = "Fajlli nuk eshte .png!------ " + ex.Message + "--------" + ex.InnerException; return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public void UpdateUser(tblPerdoruesit Perdoruesit) { context.Entry(Perdoruesit).State = EntityState.Modified; }