public static bool Create(T_Notification notification, T_User user, T_Event myevent) { using (ConcertFinderEntities bdd = new ConcertFinderEntities()) { try { T_Event a_event = bdd.T_Event.Where(x => x.Id == myevent.Id).FirstOrDefault(); T_User a_user = bdd.T_User.Where(x => x.Id == user.Id).FirstOrDefault(); bdd.Attach(a_event); bdd.Attach(a_user); notification.T_Event.Add(a_event); notification.T_User.Add(a_user); bdd.T_Notification.AddObject(notification); bdd.SaveChanges(); } catch (Exception) { throw; } } return true; }
public static void SaveImage(FormEventModels myevent, T_Event evnt) { var destinationFolder = HttpContext.Current.Server.MapPath("~/Download"); var postedFile = myevent.FileImage; if (postedFile != null && postedFile.ContentLength > 0) { var fileName = Path.GetFileName(postedFile.FileName); var path = Path.Combine(destinationFolder, fileName); postedFile.SaveAs(path); var hashpath = Path.Combine(destinationFolder, Serializer.NameFile(fileName)); ResizeImage(path, hashpath, 300, 400, false); SuppressOriginalImage(path); evnt.Image = hashpath; } }
public static List<EventItem> GetListEventByUserTag (T_Event myevent, T_User user, int nb) { List<EventItem> listRes = new List<EventItem>(); List<T_Event> listEvent = new List<T_Event>(); listEvent = DataAccess.Event.GetListEventByUserTag(myevent, user, nb); foreach (T_Event myev in listEvent) { EventItem eventItem = new EventItem() { Id = myev.Id, Titre = myev.Titre, Description = myev.Description, Type = myev.Type, StartDate = myev.DateDebut, EndDate = myev.DateFin.GetValueOrDefault(), Salle = myev.T_Location.Name, Email = myev.Email, Tel = myev.Tel, Website = myev.WebSite, CP = myev.T_Location.CP, Ville = myev.T_Location.Ville, Rue = myev.T_Location.Rue }; ServerPathImage(myev, eventItem); listRes.Add(eventItem); } return listRes; }
public static void ServerPathImage(T_Event myevent, EventItem myeventitem) { if (myevent.Image != null) { var tab = myevent.Image.Split('\\'); var path = "Download/" + tab[tab.Length - 1]; myeventitem.Image = path; } }
/// <summary> /// Create a new T_Event object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="dateDebut">Initial value of the DateDebut property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="titre">Initial value of the Titre property.</param> /// <param name="type">Initial value of the Type property.</param> public static T_Event CreateT_Event(global::System.Int64 id, global::System.DateTime dateDebut, global::System.String description, global::System.String titre, global::System.String type) { T_Event t_Event = new T_Event(); t_Event.Id = id; t_Event.DateDebut = dateDebut; t_Event.Description = description; t_Event.Titre = titre; t_Event.Type = type; return t_Event; }
/// <summary> /// Deprecated Method for adding a new object to the T_Event EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToT_Event(T_Event t_Event) { base.AddObject("T_Event", t_Event); }