public ActionResult Edit(PERMISSION _permission) { if (ModelState.IsValid) { database.Entry(_permission).State = EntityState.Modified; database.SaveChanges(); return(RedirectToAction("Details", new RouteValueDictionary(new { id = _permission.Permission_Id }))); } return(View(_permission)); }
public ActionResult Delete(int id) { Folders _folder = database.Folders.Find(id); database.Entry(_folder).State = EntityState.Deleted; database.SaveChanges(); //string path = _folder.Name + "/"; //if (System.IO.File.Exists(Server.MapPath(path))) //{ // DirectoryInfo dir = new DirectoryInfo(Server.MapPath(path)); // dir.GetFiles("*", SearchOption.AllDirectories).ToList().ForEach(file => file.Delete()); // Directory.Delete(Server.MapPath(_folder.Name),true); //} return(RedirectToAction("Index")); }
public ActionResult Edit(Signatures sig) { sig.UpdateTime = DateTime.Now.ToString(); db.Entry(sig).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { LOG_ACCESS log = database.LOG_ACCESS.Find(id); database.Entry(log).State = EntityState.Deleted; database.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { FILE file = database.FILES.Find(id); database.Entry(file).State = EntityState.Deleted; database.SaveChanges(); if (System.IO.File.Exists(Server.MapPath(file.path))) { System.IO.File.Delete(Server.MapPath(file.path)); } return(RedirectToAction("Index")); }
public ActionResult Edit(ROLE _role) { if (string.IsNullOrEmpty(_role.RoleDescription)) { ModelState.AddModelError("Role Description", "Role Description must be entered"); } //EntityState state = database.Entry(_role).State; USER user = database.USERS.Where(r => r.User_Id == _Identity.UserId).FirstOrDefault(); if (ModelState.IsValid) { database.Entry(_role).State = EntityState.Modified; database.SaveChanges(); return(RedirectToAction("Details", new RouteValueDictionary(new { id = _role.Role_Id }))); } // USERS combo ViewBag.UserId = new SelectList(database.USERS, "User_Id", "Username"); // Rights combo ViewBag.PermissionId = new SelectList(database.PERMISSIONS.OrderBy(a => a.Permission_Id), "Permission_Id", "PermissionDescription"); ViewBag.List_boolNullYesNo = StringHelper.List_boolNullYesNo(); return(View(_role)); }
public ActionResult Edit(Templates _temp, bool?IsChecked) { if (ModelState.IsValid) { var Identity = (IdentityUser)Session["Identity"]; _temp.UpdateTime = DateTime.Now.ToShortDateString(); _temp.LastUpdatedBy = Identity.UserName; _temp.Active = true; //if (IsChecked == true) // _temp.Active = true; //else // _temp.Active = false; db.Entry(_temp).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Edit(DistributorModel dis, bool?IsChecked) { if (ModelState.IsValid) { if (IsChecked == true) { dis.State = true; } else { dis.State = false; } db.Entry(dis).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Index(MailConfig r) { db.Entry(r).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Region r) { db.Entry(r).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ImportContactList(FileModel _model) { int id = Convert.ToInt32(_model.folder); var Identity = (IdentityUser)Session["Identity"]; HttpPostedFileBase FileUpload = _model.files[0]; if (ModelState.IsValid) { if (FileUpload != null) { // tdata.ExecuteCommand("truncate table OtherCompanyAssets"); if (FileUpload.ContentType == "application/vnd.ms-excel" || FileUpload.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { string nameFolder = db.ContactLists.Where(ta => ta.ID == id).SingleOrDefault().Name; var InputFileName = Path.GetFileName(FileUpload.FileName); string path = "/Files/ContactList/" + nameFolder + "/"; bool exists = System.IO.Directory.Exists(Server.MapPath(path)); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(path)); } var ServerSavePath = Path.Combine(Server.MapPath(path) + InputFileName); FileUpload.SaveAs(ServerSavePath); ViewBag.UploadStatus = _model.files.Count().ToString() + " files uploaded successfully."; string pathToExcelFile = Server.MapPath(path) + FileUpload.FileName; var connectionString = ""; if (InputFileName.EndsWith(".xls")) { connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", pathToExcelFile); } else if (InputFileName.EndsWith(".xlsx")) { connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", pathToExcelFile); } var adapter = new OleDbDataAdapter("SELECT * FROM [Excel_ContactList$]", connectionString); var ds = new DataSet(); adapter.Fill(ds, "ExcelTable"); DataTable dtable = ds.Tables["ExcelTable"]; string sheetName = "Excel_ContactList"; var excelFile = new ExcelQueryFactory(pathToExcelFile); var dataExcel = from a in excelFile.Worksheet <Contact>(sheetName) select a; List <Contact> Contacts = new List <Contact>(); var _contactRemove = db.Contacts.Where(ta => ta.ContactListID == id).ToList(); if (_contactRemove.Count > 0) { foreach (var item in _contactRemove) { db.Contacts.Remove(item); db.SaveChanges(); } var ContactList = db.ContactLists.Where(ta => ta.ID == id).SingleOrDefault(); ContactList.ID = ContactList.ID; ContactList.Name = ContactList.Name; ContactList.Remarks = ContactList.Remarks; ContactList.Description = ContactList.Description; ContactList.CreatedBy = ContactList.CreatedBy; ContactList.LastUpdatedBy = Identity.UserName; ContactList.LastUpdateTime = DateTime.Now; ContactList.LastImportFileName = InputFileName; db.Entry(ContactList).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } foreach (var item in dataExcel) { try { if (item.Email != "") { Contact TU = new Contact(); TU.Name = item.Name; TU.Address = item.Address; TU.Email = item.Email; TU.Phone = item.Phone; TU.Remarks = item.Remarks; TU.Company = item.Company; TU.ContactListID = id; db.Contacts.Add(TU); db.SaveChanges(); Contacts.Add(TU); } } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } } } } } return(RedirectToAction("Details", new { id = id })); }