Example #1
0
 public PublicationLiteModel(ConnextBusinessLayer.Bdd.PUBLICATION objBdd)
 {
     Id               = objBdd.ID_PUBLICATION;
     Title            = objBdd.TITLE;
     Description      = objBdd.DESCRIPTION;
     User             = new UserBaseModel(objBdd.USER);
     DateTimeCreation = objBdd.DATE_TIME_CREATION;
 }
Example #2
0
 public PublicationModel(ConnextBusinessLayer.Bdd.PUBLICATION objBdd)
 {
     Id          = objBdd.ID_PUBLICATION;
     Group       = new GroupLiteModel(objBdd.GROUP);
     Title       = objBdd.TITLE;
     Description = objBdd.DESCRIPTION;
     Category    = new CategoryModel(objBdd.CATEGORY);
 }
Example #3
0
        public void remove(PUBLICATION publication)
        {
            try
            {
                var Context = new connext_dbEntities();
                Context.PUBLICATIONs.Remove(publication);
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
            #if DEBUG
                throw new Exception("Impossible de supprimer le lieu." + Environment.NewLine + ex.StackTrace);
            #else
                throw new Exception("Impossible de supprimer le lieu.");

            #endif
            }
        }
Example #4
0
        public void add(TRAVEL travel, PUBLICATION publication)
        {
            try
            {
                var Context = new connext_dbEntities();
                publication.TRAVELs.Add(travel);
                Context.PUBLICATIONs.Add(publication);
                Context.SaveChanges();
            }
            catch (Exception ex)
            {
            #if DEBUG
                throw new Exception("Impossible de modifier le covoiturage." + Environment.NewLine + ex.StackTrace);
            #else
                throw new Exception("Impossible de modifier le covoiturage.");

            #endif
            }
        }
Example #5
0
        // POST api/values
        public HttpResponseMessage Post(TravelEditModel model)
        {
            if (HttpContext.Current.Request.Headers["Authorization"] == null)
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }
            else
            {
                try
                {
                    TRAVEL travelBdd = new TRAVEL();
                    travelBdd.ID_ARRIVALAGENCY = model.ArrivalAgency.Id;
                    travelBdd.ID_DEPARTUREAGENCY = model.DepartureAgency.Id;
                    travelBdd.ARRIVALHOUR = model.ArrivalTime;
                    travelBdd.DEPARTUREHOUR = model.DepartureTime;
                    travelBdd.CAPACITY = model.Capacity;

                    PUBLICATION publicationBdd = new PUBLICATION();

                    string tokenString = HttpContext.Current.Request.Headers["Authorization"];
                    UserManager userManager = new UserManager();
                    publicationBdd.ID_USER = userManager.getUserFromSession(new Guid(tokenString));
                    publicationBdd.TITLE = model.Publication.Title;
                    publicationBdd.DESCRIPTION = model.Publication.Description;
                    publicationBdd.ID_GROUP = 1;
                    publicationBdd.ID_CATEGORY = 1;
                    publicationBdd.DATE_TIME_CREATION = DateTime.Now.AddHours(1);

                    manager.add(travelBdd, publicationBdd);
                    return new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Success = true, //error
                            Message = "Success" //return exception
                        })
                    };
                }
                catch(Exception e)
                {
                    return new HttpResponseMessage()
                    {
                        Content = new JsonContent(new
                        {
                            Success = false, //error
                            Message = "Exception with token :" + HttpContext.Current.Request.Headers["Authorization"] + " Error :" + e.ToString() //return exception
                        })
                    };
                }
            }
        }