示例#1
0
 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;
     }
 }
示例#2
0
        public ActionResult CreateEvent(FormEventModels form)
        {
            if (ModelState.IsValid && User.Identity.IsAuthenticated)
            {
                if (form.Id == 0)
                {
                    DataAccess.T_User user = BusinessManagement.User.GetUserByPseudo(User.Identity.Name);
                    if (user != null && BusinessManagement.Event.Create(form, user))
                    {
                        DataAccess.T_Event bdd_event = BusinessManagement.Event.Get(form.Title, true);
                        BusinessManagement.Notification.Create(user, bdd_event);
                        return RedirectToAction("Detail", "Event", new { id = bdd_event.Id, creation = true });
                    }
                    else
                    {
                        return View("Error");
                    }
                }
                else
                {
                    DataAccess.T_User user = new T_User();
                    user = BusinessManagement.User.GetUserByPseudo(User.Identity.Name);
                     
                    if (user != null && BusinessManagement.Event.Update(form, User.Identity.Name))
                    {
                        DataAccess.T_Event bdd_event = BusinessManagement.Event.Get(form.Id, true);
                        BusinessManagement.Notification.Update(user, bdd_event);
                        return RedirectToAction("Detail", "Event", new { id = bdd_event.Id, creation = true });
                    }
                }

            }
            return View(form);
        }
示例#3
0
        public ActionResult CreateEvent(long? id)
        {
            try
            {
                FormEventModels form;
                if (id.HasValue)
                {
                    T_Event myevent = BusinessManagement.Event.Get(id.Value, true);
                    string tags = "";
                    foreach (T_Tag tag in myevent.T_Tag.ToList())
                    {
                        tags += tag.Name + " ";
                    }

                    form = new FormEventModels()
                    {
                        Id = myevent.Id,
                        StartDate = myevent.DateDebut,
                        EndDate = myevent.DateFin.GetValueOrDefault(),
                        Description = myevent.Description,
                        Title = myevent.Titre,
                        Email = myevent.Email,
                        Phone = myevent.Tel,
                        Website = myevent.WebSite,
                        Type = (int)EventModel.GetEventType(myevent.Type),
                        Tags = tags,

                        RoomName = myevent.T_Location.Name,
                        Country = myevent.T_Location.Pays,
                        City = myevent.T_Location.Ville,
                        CodePostal = myevent.T_Location.CP,
                        Address = myevent.T_Location.Rue,
                        Latitude = myevent.T_Location.Latitude,
                        Longitude = myevent.T_Location.Longitude
                    };
                }
                else
                {
                    form = new FormEventModels();
                }

                return View(form);
            }
            catch
            {
                return View("Error");
            }
        }
示例#4
0
 static public bool Update(FormEventModels myevent, string pseudo)
 { 
     return DataAccess.Event.Update(myevent, pseudo);
 }
示例#5
0
        static public bool Create(FormEventModels myevent, DataAccess.T_User user)
        {
            DataAccess.T_Event ev = new DataAccess.T_Event ()
            {
                Titre = myevent.Title,
                Type = EventModel.GetEventType(myevent.Type),
                Description = myevent.Description,
                DateDebut = myevent.StartDate,
                DateFin= myevent.EndDate,
                Email = myevent.Email,
                WebSite = myevent.Website,
                Tel = myevent.Phone,
                Valide = false
            };
            SaveImage(myevent, ev);

            List<DataAccess.T_Tag> list_tag = new List<DataAccess.T_Tag>();
            List<String> tags = myevent.Tags.Split(new Char[] { ' ', ',', '.', ';'}).ToList();
            foreach (String tag in tags)
            {
                Regex regx = new Regex("[a-z1-9*]");
                if (tag.Length > 2 && regx.Match(tag).Success)
                {
                    tag.ToLower();
                    DataAccess.T_Tag bdd_tag = BusinessManagement.Tag.Get(tag);
                    if (bdd_tag != null)
                    {
                        list_tag.Add(bdd_tag);
                    }
                    else
                    {
                        BusinessManagement.Tag.Create(tag);
                        bdd_tag = BusinessManagement.Tag.Get(tag);
                        list_tag.Add(bdd_tag);
                    }
                }
            }

            DataAccess.T_Location location = Location.GetLocationByCoord(myevent.Latitude, myevent.Longitude);
            if (location != null)
            {
                return DataAccess.Event.Create(ev, user, location, list_tag);
            }
            else
            {
                if (BusinessManagement.Location.Create(new DataAccess.T_Location()
                                                        {
                                                            Pays = myevent.Country,
                                                            Ville = myevent.City,
                                                            CP = myevent.CodePostal,
                                                            Rue = myevent.Address,
                                                            Name = myevent.RoomName,
                                                            Latitude = myevent.Latitude,
                                                            Longitude = myevent.Longitude
                                                        }))
                {
                    DataAccess.T_Location n_location = Location.GetLocationByCoord(myevent.Latitude, myevent.Longitude);
                    return DataAccess.Event.Create(ev, user, n_location, list_tag);
                }
                else
                {
                    return false;
                }
            }
        }