示例#1
0
        public IHttpActionResult PutArea(int id, Area area)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != area.Id)
            {
                return(BadRequest());
            }

            db.Entry(area).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AreaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
 public async Task <Souscription> AddSouscription(int idApplet, string idUser, string city = null, string streamer = null, string fbToken = null, string fbIdPage = null, string twitterToken = null, string twitterSecret = null)
 {
     _db.Souscriptions.Add(new Souscription {
         AppletId = idApplet, UserId = idUser, City = city, Streamer = streamer, FbToken = fbToken, FbPageId = fbIdPage, TwitterToken = twitterToken, TwitterSecret = twitterSecret
     });
     _db.SaveChanges();
     return(await _db.Souscriptions.FirstOrDefaultAsync(x => x.AppletId == idApplet && x.UserId == idUser));
 }
示例#3
0
 public static void EnsureSeedData(this AreaContext db)
 {
     if (!db.Services.Any())
     {
         List <Service> services = new List <Service>()
         {
             new Service()
             {
                 Name = "OpenWeatherMap"
             },
             new Service()
             {
                 Name = "Youtube"
             },
             new Service()
             {
                 Name = "Twitch"
             },
             new Service()
             {
                 Name = "Twitter"
             },
             new Service()
             {
                 Name = "Facebook"
             },
             new Service()
             {
                 Name = "Github"
             },
             new Service()
             {
                 Name = "Gmail"
             }
         };
         db.AddRange(services);
         db.SaveChanges();
     }
     if (!db.Applets.Any())
     {
         List <Applet> applets = new List <Applet>()
         {
             new Applet()
             {
                 description = "Envoyer un mail pour la météo courante", IdServiceIn = 1, IdServiceOut = 7
             },
             new Applet()
             {
                 description = "Prévenir quand il pleut", IdServiceIn = 1, IdServiceOut = 7
             },
             new Applet()
             {
                 description = "Envoie de mail quand un streamer est en live", IdServiceIn = 3, IdServiceOut = 7
             },
             new Applet()
             {
                 description = "Tweeter la météo du jour", IdServiceIn = 1, IdServiceOut = 4
             },
             new Applet()
             {
                 description = "Tweeter quand un streamer est en live", IdServiceIn = 3, IdServiceOut = 4
             },
             new Applet()
             {
                 description = "Poster la météo du jour", IdServiceIn = 1, IdServiceOut = 5
             },
             new Applet()
             {
                 description = "Poster quand un streamer est en live", IdServiceIn = 3, IdServiceOut = 5
             },
             new Applet()
             {
                 description = "Envoyer un mail quand il y a un nouveau push etc", IdServiceIn = 6, IdServiceOut = 7
             },
             new Applet()
             {
                 description = "Tweeter quand il y a un nouveau push etc", IdServiceIn = 6, IdServiceOut = 4
             },
             new Applet()
             {
                 description = "Poster sur Facebook quand y a un nouveau push", IdServiceIn = 6, IdServiceOut = 5
             },
             new Applet()
             {
                 description = "Poster sur Twitter quand y a un repo delete", IdServiceIn = 6, IdServiceOut = 4
             },
             new Applet()
             {
                 description = "Poster sur Facebook quand y a un repo delete", IdServiceIn = 6, IdServiceOut = 5
             },
             new Applet()
             {
                 description = "Liker le dernier post Facebook", IdServiceIn = 5, IdServiceOut = 5
             },
             new Applet()
             {
                 description = "Répondre au dernier post Facebook", IdServiceIn = 5, IdServiceOut = 5
             },
             new Applet()
             {
                 description = "envoyer un email quand un repo est deleted", IdServiceIn = 6, IdServiceOut = 7
             }
         };
         db.AddRange(applets);
         db.SaveChanges();
     }
 }
示例#4
0
 public int DeleteWidgetConf(WidgetConfModel model)
 {
     _repository.Remove(model);
     return(_context.SaveChanges());
 }
示例#5
0
 public int UpdateUser(UserUpdateModel updatedUser, UserModel target)
 {
     _context.Entry(target).CurrentValues.SetValues(updatedUser);
     return(_context.SaveChanges());
 }