예제 #1
0
        public static Involvement[] GetAllInvolvements(string AccountID)
        {
            var output = Query.ExecuteReturnCommand(String.Format("SELECT * FROM HelloWorld.Involvements WHERE Accounts_ID = '{0}';", AccountID));

            List <Involvement> posts = new List <Involvement>();

            for (int x = 0; x < output.Rows.Count; x++)
            {
                Involvement newInvolvement = new Involvement();
                newInvolvement.Posts_PostID = output.Rows[x].ItemArray[0].ToString();
                newInvolvement.AccountsID   = output.Rows[x].ItemArray[1].ToString();

                int isHost = Convert.ToInt32(output.Rows[x].ItemArray[2].ToString());
                if (isHost > 0)
                {
                    newInvolvement.IsHost = true;
                }
                else
                {
                    newInvolvement.IsHost = false;
                }

                posts.Add(newInvolvement);
            }
            return(posts.ToArray());
        }
예제 #2
0
 public string[] GetData()
 {
     return(new string[] { Date.ToShortDateString(), SellsProfit.ToString() + "$", AdvsProfit.ToString() + "$",
                           DAU.ToString(), MAU.ToString(), LAU.ToString(), NewUsers.ToString(), PAU.ToString(),
                           NetworkPostsCount.ToString(), AvgSessionTime.ToString(), AvgSessionCount.ToString(),
                           ARPU.ToString(), ARPPU.ToString(), Involvement.ToString() + "%", ConversionRate.ToString() + "%" });
 }
예제 #3
0
        public static bool TryParse(this string input, out Involvement kind)
        {
            if (string.IsNullOrEmpty(input))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(input));
            }
            var match = TagEx.Match(input);

            switch (match.Captures[1].Value)
            {
            case "incl":
            {
                kind = Involvement.Incl;
                return(true);
            }

            case "excl":
            {
                kind = Involvement.Excl;
                return(true);
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(input));
            }
        }
예제 #4
0
 public IActionResult CreateInvolvement([FromBody] Involvement newInvolvement)
 {
     context.Involvements.Add(newInvolvement);
     context.SaveChanges();
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     return(Created("", newInvolvement));
 }
예제 #5
0
        public IActionResult GetInvolvement(int id)
        {
            Involvement involvement = context.Involvements.Include(d => d.Vacation).Include(d => d.Worker).Include(d => d.Profile).SingleOrDefault(d => d.InvolvementID == id);

            if (involvement == null)
            {
                return(NotFound());
            }
            return(Ok(involvement));
        }
예제 #6
0
        public IActionResult DeleteInvolvement(int id)
        {
            Involvement involvement = context.Involvements.Find(id);

            if (involvement == null)
            {
                return(NotFound());
            }
            context.Involvements.Remove(involvement);
            context.SaveChanges();
            return(NoContent());
        }
예제 #7
0
        public static string Title(this Involvement kind)
        {
            switch (kind)
            {
            case Involvement.Incl: return("говорящий включён в действие");

            case Involvement.Excl: return("говорящий не включён в действие");

            default:
                throw new ArgumentOutOfRangeException(nameof(kind), kind, "invalid kind value");
            }
        }
예제 #8
0
        public static void InsertInvolvement(Involvement involvement)
        {
            int IsHost = 0;

            if (involvement.IsHost)
            {
                IsHost = 1;
            }

            string sqlStatement = String.Format("INSERT INTO HelloWorld.Involvements(Posts_PostID, Accounts_ID, IsHost) VALUES('{0}', '{1}', '{2}');", involvement.Posts_PostID, involvement.AccountsID, IsHost);

            Query.ExecuteNonReturnCommand(sqlStatement);
        }
예제 #9
0
        public IActionResult UpdateInvolvement([FromBody] Involvement updateInvolvement)
        {
            Involvement originalInvolvement = context.Involvements.Find(updateInvolvement.InvolvementID);

            if (originalInvolvement == null)
            {
                return(NotFound());
            }

            originalInvolvement.VacationID = updateInvolvement.VacationID;
            originalInvolvement.WorkerID   = updateInvolvement.WorkerID;
            originalInvolvement.ProfileID  = updateInvolvement.ProfileID;
            context.SaveChanges();
            return(Ok(originalInvolvement));
        }
예제 #10
0
        public static void Initialize(KazouContext context)
        {
            Worker      worker      = null;
            Vacation    vacation    = null;
            Profile     profile     = null;
            Destination destination = null;

            context.Database.EnsureCreated();

            if (!context.Workers.Any())
            {
                worker = new Worker()
                {
                    FirstName    = "Thibaut",
                    LastName     = "Humblet",
                    EmailAddress = "*****@*****.**",
                    BirthDay     = DateTime.Now
                };

                context.Workers.Add(worker);
                context.SaveChanges();
            }

            if (!context.Destinations.Any())
            {
                destination = new Destination()
                {
                    Name    = "Massembre",
                    Country = "België",
                    Region  = "Ardennen"
                };

                context.Destinations.Add(destination);
                context.SaveChanges();
            }

            if (!context.Profiles.Any())
            {
                profile = new Profile()
                {
                    Name        = "Moni",
                    Description = "De animator of moni zorgt ervoor dat de kinderen een onvergetelijke vakantie hebben"
                };

                context.Profiles.Add(profile);
                context.SaveChanges();
            }

            if (!context.Vacations.Any())
            {
                vacation = new Vacation()
                {
                    Name        = "Crazy Adventure",
                    Destination = destination,
                    StartDate   = DateTime.Now,
                    EndDate     = DateTime.Now.AddDays(7)
                };

                context.Vacations.Add(vacation);
                context.SaveChanges();
            }

            if (!context.Involvements.Any())
            {
                var involvement = new Involvement()
                {
                    Vacation = vacation,
                    Worker   = worker,
                    Profile  = profile
                };

                context.Involvements.Add(involvement);
                context.SaveChanges();
            }
        }