/// <summary> /// createtime expiresetime不用传。 /// </summary> /// <param name="PubConn"></param> /// <param name="model"></param> /// <param name="tokentype"></param> /// <returns></returns> public virtual bool Add(DbConn PubConn, DbModels.tb_token model, Models.DbModels.TokenType tokentype) { DateTime nowtime = PubConn.GetServerDate(); model.createtime = nowtime; model.expires = nowtime.AddMinutes(GetExpiresminutes(tokentype)); List<ProcedureParameter> Par = new List<ProcedureParameter>() { // new ProcedureParameter("@token", model.token), // new ProcedureParameter("@userid", model.userid), new ProcedureParameter("@id", model.id), // new ProcedureParameter("@username", model.username), // new ProcedureParameter("@appid", model.appid), // new ProcedureParameter("@createtime", model.createtime), // new ProcedureParameter("@expires", model.expires ) }; int rev = PubConn.ExecuteSql("insert into " + tokentype.ToString() + " (token,userid,id,username,appid,createtime,expires)" + " values(@token,@userid,@id,@username,@appid,@createtime,@expires)", Par); return rev == 1; }
// GET: AdminLocation public ActionResult Index() { using (DbModels dbModel = new DbModels()) { var locations = dbModel.Locations.ToList(); return(View(locations)); } }
public ActionResult Delete(int id) { using (DbModels db = new DbModels()) { Employee emp = db.Employees.Where(x => x.EmployeeID == id).FirstOrDefault <Employee>(); db.Employees.Remove(emp); db.SaveChanges(); return(Json(new { success = true, message = "removed successfully" }, JsonRequestBehavior.AllowGet)); } }
// GET: AdminHotel public ActionResult Index() { using (DbModels dbModel = new DbModels()) { var hotel = dbModel.Hotels.ToList(); return(View(hotel)); } }
public ActionResult View(int id) { Image imageModel = new Image(); using (DbModels db = new DbModels()) { imageModel = db.Images.Where(x => x.ImageID == id).FirstOrDefault(); } return(View(imageModel)); }
public ActionResult Delete(int id, FormCollection collection) { using (DbModels dbModel = new DbModels()) { User user = dbModel.Users.Where(x => x.Id == id).FirstOrDefault(); dbModel.Users.Remove(user); dbModel.SaveChanges(); } return(RedirectToAction("Index", "User")); }
public ActionResult Index() { List <Image> imageModel = new List <Image>(); using (DbModels db = new DbModels()) { imageModel = db.Images.ToList(); } return(View(imageModel)); }
public ActionResult Eliminar(String codigo_juego, FormCollection collection) { using (DbModels dbModel = new DbModels()) { Juego_Favorito juego_Favorito = dbModel.Juego_Favorito.Where(x => x.codigo_juego == codigo_juego).FirstOrDefault(); dbModel.Juego_Favorito.Remove(juego_Favorito); dbModel.SaveChanges(); } return(RedirectToAction("List")); }
// GET: AdminBlog public ActionResult Index() { using (DbModels dbModel = new DbModels()) { var blog = dbModel.Blogs.ToList(); return(View(blog)); } }
public ActionResult Editar(String codigo_juego, Juego_Favorito juego_Favorito) { using (DbModels dbModel = new DbModels()) { dbModel.Entry(juego_Favorito).State = System.Data.Entity.EntityState.Modified; dbModel.SaveChanges(); } return(RedirectToAction("List")); }
// GET: AdminTourGuide public ActionResult Index() { using (DbModels dbModel = new DbModels()) { var tourguide = dbModel.TourGuides.ToList(); return(View(tourguide)); } }
// GET: Product public ActionResult Index() { ProductModel product = new ProductModel(); using (DbModels db = new DbModels()) { product.Products = db.tProducts.ToList <tProduct>(); } return(View(product)); }
public ActionResult uploade() { bool isSavedSuccessfully = true; string fname = ""; try { using (DbModels dbModel = new DbModels()) { foreach (string filename in Request.Files) { HttpPostedFileBase file = Request.Files[filename]; fname = file.FileName; if (file != null && file.ContentLength > 0) { var path = Path.Combine(Server.MapPath("~/Assets/Image/Account/")); string pathstring = Path.Combine(path.ToString()); string filename1 = Guid.NewGuid() + Path.GetExtension(file.FileName); bool isexist = Directory.Exists(pathstring); if (!isexist) { Directory.CreateDirectory(pathstring); } string uploadpath = string.Format("{0}\\{1}", pathstring, filename1); Image im = new Image(); im.customerId = 8; im.image1 = filename1; dbModel.Images.Add(im); file.SaveAs(uploadpath); } } dbModel.SaveChanges(); } } catch (Exception) { isSavedSuccessfully = false; } if (isSavedSuccessfully) { return(Json(new { Message = fname })); } else { return(Json(new { Message = "Error in Saving file" })); } }
// Replaces the Index of the ASP.NET with an image that randomised everytime the user refreshes // the page. public ActionResult Index() { Random rnd = new Random(); Image img = new Image(); using (DbModels db = new DbModels()) { img = db.Images.Find(rnd.Next(1, 11)); } return(View(img)); }
public ActionResult Delete(int id) { DbModels db = new DbModels(); var getdata = db.Images.Find(id); db.Images.Remove(getdata); //string path = getdata.ImagePath; //db.Entry(getdata).State = EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult ContactUsView(ContactU model) { using (DbModels dbModel = new DbModels()) { dbModel.ContactUs.Add(model); dbModel.SaveChanges(); } ModelState.Clear(); ViewBag.SuccessMessage = "Success!"; return(View()); }
public ActionResult AddOrEdit(dbo_User userModel) { using (DbModels dbModel = new DbModels()) { dbModel.dbo_User.Add(userModel); dbModel.SaveChanges(); } ModelState.Clear(); ViewBag.SuccessMessage = "Registration Successful. "; return(View("AddOrEdit", new dbo_User())); }
public ActionResult Create() { TModel theModel = new TModel(); using (DbModels dbModel = new DbModels()) { theModel.ListOfBrands = dbModel.TBrands.ToList <TBrand>(); return(View(theModel)); } }
/// <summary> /// Get Notification Box list for a particular user /// </summary> /// <param name="myID">User's ID</param> /// <param name="onlyNew">Only get list of "New" Notifications</param> /// <returns></returns> public List <NotificationBox> GetNotificationsForUser(int myID, bool onlyNew) { var notificationList = new List <NotificationBox>(); var myRole = GetUserRole(myID); List <Notification> notifications; List <NotificationStatus> notificationStatuses; using (var context = new DbModels()) { IQueryable <Notification> query; //If you are an Admin then get all Notifications (but don't set them as Seen (unless they are assigned to you!)) if (myRole == Role.RoleTypes.Admin) { query = context.Notifications.AsQueryable(); } else //Get Notifications Assigned to you { query = context.Notifications.Where(m => m.AssignedTo == myID); } //Only grab the new Notifications not seen if (onlyNew == true) { query = query.Where(m => m.New == true); } //Order by newest first query = query.OrderByDescending(m => m.CreatedOn); notifications = query.ToList(); //Get all the types of notifications to get the correct formatting notificationStatuses = context.NotificationStatus.ToList(); } //Go through all the Notifications and create a usable NotificationBox object for each to return in the list NotificationBox currentNote; NotificationStatus currentNoteStatus; foreach (var note in notifications) { //Get the correct status type for the current Notification currentNoteStatus = notificationStatuses.Where(m => m.value == note.Type).FirstOrDefault(); currentNote = new NotificationBox() { isNew = note.New, text = GetNotificationText(note, currentNoteStatus), type = (Notification.Types)note.Type }; notificationList.Add(currentNote); } SetNotificationToViewed(myID); //Set the ones belonging to you to false return(notificationList); }
public ActionResult List() { Hotel obj = new Hotel(); using (DbModels dbModel = new DbModels()) { //obj = db.images.Where(x => x.id == id).First(); var list = dbModel.Hotels.ToList(); return(View(list)); } }
public ActionResult Sell() { TUser theUser = new TUser(); using (DbModels dbModel = new DbModels()) { theUser.ListOfBrands = dbModel.TBrands.ToList <TBrand>(); theUser.ListOfModels = dbModel.TModels.ToList <TModel>(); return(View(theUser)); } }
public ActionResult Delete(int id) { using (DbModels dbModel = new DbModels()) { var query = dbModel.Hotels.Where(x => x.HotelId == id).First(); dbModel.Hotels.Remove(query); dbModel.SaveChanges(); var list = dbModel.Hotels.ToList(); return(View("List", list)); } }
public ActionResult BlogPostView(Blog blogModel) { using (DbModels dbModel = new DbModels()) { blogModel.UserId = (int)Session["userId"]; dbModel.Blogs.Add(blogModel); dbModel.SaveChanges(); } ModelState.Clear(); ViewBag.SuccessMessage = "Success!"; return(View()); }
public ActionResult Create(EventTable eventTable) { using (DbModels dbModels = new DbModels()) { //var tempId = (from c in dbModels.EventTable select eventTable.Id).Max(); //tempId++; //eventTable.Id = tempId; dbModels.EventTable.Add(eventTable); dbModels.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult AddOrEdit(User userModel) { using (DbModels dbModel = new DbModels()) { userModel.Date = DateTime.Now; dbModel.User.Add(userModel); dbModel.SaveChanges(); } ModelState.Clear(); /*return View("AddOrEdit", new User());*/ return(RedirectPermanent("~/Home/Contact")); }
/// <summary> /// Get a Work Item by its ID /// </summary> /// <param name="id"></param> /// <returns></returns> public Item GetWorkItemFromID(int id) { Item item = null; using (var context = new DbModels()) { item = context.Items.Where(m => m.Id == id) .Include(m => m.ItemHistories) .FirstOrDefault(); item.UserAssignedTo = context.Users.Where(m => m.Id == item.AssignedTo).FirstOrDefault(); } return(item); }
public User GetUser(int myId) { User user = null; using (var context = new DbModels()) { user = context.Users.Where(m => m.Id == myId) .Include(m => m.UserRoles) .FirstOrDefault(); } formatUser(user); return(user); }
public ActionResult Add(Image imageModel) { // System.Drawing.Image img = System.Drawing.Image.FromFile("C:/Users/18651/source/repos/WebApplication1/WebApplication1/Image/IMG_8148183549382.JPG"); System.Drawing.Image originalImage = System.Drawing.Image.FromStream(imageModel.ImageFile.InputStream); if (originalImage.PropertyIdList.Contains(0x0112)) { int rotationValue = originalImage.GetPropertyItem(0x0112).Value[0]; switch (rotationValue) { case 1: // landscape, do nothing break; case 8: // rotated 90 right // de-rotate: originalImage.RotateFlip(rotateFlipType: System.Drawing.RotateFlipType.Rotate270FlipNone); break; case 3: // bottoms up originalImage.RotateFlip(rotateFlipType: System.Drawing.RotateFlipType.Rotate180FlipNone); break; case 6: // rotated 90 left originalImage.RotateFlip(rotateFlipType: System.Drawing.RotateFlipType.Rotate90FlipNone); break; } } string fileName = Path.GetFileNameWithoutExtension(imageModel.ImageFile.FileName); string extension = Path.GetExtension(imageModel.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; imageModel.ImagePath = "~/Image/" + fileName; fileName = Path.Combine(Server.MapPath("~/Image/"), fileName); imageModel.ImageFile.SaveAs(fileName); using (DbModels db = new DbModels()) { db.Images.Add(imageModel); db.SaveChanges(); } originalImage.Save(fileName); ModelState.Clear(); return(View()); }
public ActionResult AddOrEdit(int id = 0) { Employee emp = new Employee(); if (id != 0) { using (DbModels db = new DbModels()) { emp = db.Employees.Where(x => x.EmployeeId == id).FirstOrDefault <Employee>(); } } return(View(emp)); }
public List <User> GetOwners() { List <User> ownerList = new List <User>(); using (var context = new DbModels()) { ownerList = (from u in context.Users join r in context.UserRoles on u.Id equals r.userId where r.roleId == (int)Role.RoleTypes.Owner select u).ToList(); } return(ownerList); }
public ActionResult AddOrEdit(Usuario userModel) { CaptchaResponse response = ValidateCaptcha(Request["g-recaptcha-response"]); Mail mail = new Mail(); using (DbModels dbModel = new DbModels()) { if (dbModel.Usuario.Any(x => x.correo == userModel.correo)) { Debug.WriteLine("Ya existe un usuario con ese correo"); ViewBag.Error = "Ya existe un usuario con ese correo"; return(View("AddOrEdit", new Usuario())); } else { if (!passwordSecurity(userModel.contraseña)) { Debug.WriteLine("La contraseña no es segura"); ViewBag.Error = "La contraseña debe tener una longitud de al menos 7 dígitos, 6 caracteres, un caracter en mayúscula" + ", un número y un carácter alfanumérico"; } else { if (!mail.email_bien_escrito(userModel.correo)) { Debug.WriteLine("correo invalido"); ViewBag.Error = "Correo invalido"; return(View("AddOrEdit", new Usuario())); } else { if (response.Success) { Debug.WriteLine("Usuario registrado correctamente"); ViewBag.Error = "Usuario registrado correctamente"; dbModel.Usuario.Add(userModel); mail.SendEmail(userModel.correo); dbModel.SaveChanges(); } else { ViewBag.Error = "Captcha incorrecto"; } } } } } return(View("AddOrEdit", new Usuario())); }
public static void AddLog(XXF.Db.DbConn PubConn,DbModels.apilog log) { XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter(); para.Add("@reqsource", log.reqsource); para.Add("@url", log.url); para.Add("@reqpara", log.reqpara); para.Add("@token", log.token); para.Add("@appid", log.appid); // para.Add("@appname", log.appname); para.Add("@userid", log.userid); para.Add("@username", log.username); para.Add("@reqdate", log.reqdate); para.Add("@opecontent", log.opecontent); string sql = "INSERT INTO operationlog (reqsource ,url ,reqpara ,token ,appid ,appname,userid ,username ,reqdate ,opecontent)"+ "VALUES (@reqsource,@url, @reqpara,@token,@appid,@appname,@userid, @username,@reqdate,@opecontent)"; PubConn.ExecuteSql(sql, para.ToParameters()); }
internal string getUserName(XXF.Db.DbConn PubConn, string userid, DbModels.TokenType tokentype) { CertCenter.Models.DbModels.manage model = null; switch (tokentype) { case DbModels.TokenType.usertoken: model = getUser(PubConn, userid);break; case DbModels.TokenType.managetoken: model = getManage(PubConn, userid); break; case DbModels.TokenType.shoptoken: model = getShop(PubConn, userid); break; } if (model == null) return ""; return model.username; }
public virtual bool Add(DbConn PubConn, DbModels.certcenterlog model) { List<ProcedureParameter> Par = new List<ProcedureParameter>() { new ProcedureParameter("@url", model.url), // new ProcedureParameter("@reqdata", model.reqdata), // new ProcedureParameter("@userid", model.userid), new ProcedureParameter("@username", model.username), // new ProcedureParameter("@reqtime", model.reqtime), // new ProcedureParameter("@ip", model.ip), // new ProcedureParameter("@opecontent", model.opecontent) }; int rev = PubConn.ExecuteSql(@"insert into certcenterlog(url,reqdata,userid,username,reqtime,ip,opecontent) values(@url,@reqdata,@userid,@username,@reqtime,@ip,@opecontent)", Par); return rev == 1; }
public virtual bool Edit(DbConn PubConn, DbModels.certcenterlog model) { List<ProcedureParameter> Par = new List<ProcedureParameter>() { new ProcedureParameter("@url", model.url), // new ProcedureParameter("@reqdata", model.reqdata), // new ProcedureParameter("@userid", model.userid), new ProcedureParameter("@username", model.username), // new ProcedureParameter("@reqtime", model.reqtime), // new ProcedureParameter("@ip", model.ip), // new ProcedureParameter("@opecontent", model.opecontent) }; Par.Add(new ProcedureParameter("@id", model.id)); int rev = PubConn.ExecuteSql("update certcenterlog set url=@url,reqdata=@reqdata,userid=@userid,username =@username,reqtime=@reqtime,ip=@ip,opecontent=@opecontent where id=@id", Par); return rev == 1; }
public virtual bool Edit(DbConn PubConn, DbModels.tb_token model, DbModels.TokenType tokentype) { List<ProcedureParameter> Par = new List<ProcedureParameter>() { // new ProcedureParameter("@token", model.token), // new ProcedureParameter("@userid", model.userid), // new ProcedureParameter("@id", model.id), // new ProcedureParameter("@username", model.username), // new ProcedureParameter("@appid", model.appid), // new ProcedureParameter("@createtime", model.createtime), // new ProcedureParameter("@expires", model.expires) }; int rev = PubConn.ExecuteSql("update " + tokentype.ToString() + " set userid=@userid,id=@id,username=@username,appid=@appid,createtime=@createtime,expires=@expires where token=@token", Par); return rev == 1; }
public List<Models.DbModels.tb_token> GetByPage(XXF.Db.DbConn PubConn, int pno, int pagesize, string keywords, DbModels.TokenType tokentype, out int totalcount) { List<DbModels.tb_token> tokenlist = new List<DbModels.tb_token>(); string basesql = "select {0} from " + tokentype.ToString() + " "; string whercon = ""; XXF.Db.SimpleProcedureParameter para = new SimpleProcedureParameter(); string querysql = string.Format(basesql, "ROW_NUMBER() over (order by createtime desc) as rownum, token,userid,id,username,appid,createtime,expires"); if (!string.IsNullOrEmpty(keywords)) { para.Add("@keywords", keywords); whercon = " where token=@keywords or userid like '%' + @keywords + '%' or username like '%' + @keywords + '%' or appid like '%' + @keywords + '%' "; } querysql = string.Concat("select A.* from (", querysql, whercon, ") A ", " where A.rownum between ", (pno - 1) * pagesize + 1, " and ", pagesize * pno); DataSet ds = new DataSet(); PubConn.SqlToDataSet(ds, querysql, para.ToParameters()); foreach (DataRow dr in ds.Tables[0].Rows) { tokenlist.Add(CreateModel(dr)); } totalcount = (int)PubConn.ExecuteScalar(string.Format(basesql, " count(*) ") + whercon, para.ToParameters()); return tokenlist; }
public Models.DbModels.tb_token GetToken(DbConn PubConn, string token, DbModels.TokenType tokentype) { string sql = " select token,userid,id,username,appid,createtime,expires from " + tokentype.ToString() + " where token=@token"; List<ProcedureParameter> Par = new List<ProcedureParameter>(); Par.Add(new ProcedureParameter("@token", token)); DataSet ds = new DataSet(); PubConn.SqlToDataSet(ds, sql, Par); if (ds.Tables[0].Rows.Count != 1) return null; return CreateModel(ds.Tables[0].Rows[0]); }
public virtual bool Delete(DbConn PubConn, string id, DbModels.TokenType tokentype) { List<ProcedureParameter> Par = new List<ProcedureParameter>(); Par.Add(new ProcedureParameter("@token", id)); string Sql = "delete from " + tokentype.ToString() + " where token=@token"; int rev = PubConn.ExecuteSql(Sql, Par); if (rev == 1) { return true; } else { return false; } }