示例#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;
 }
示例#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);
 }
示例#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
            }
        }
示例#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
            }
        }
示例#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
                        })
                    };
                }
            }
        }