public string postApplication(Application newApplication)
        {
            if (newApplication != null)
            {

                string RegNum = "";
                if (getAllApplications().ToList().Count == 0)
                {
                    RegNum = "1-{";

                }
                else
                {
                    var LastApplication = getAllApplications().Select(a => a).Last();
                    int lastIndex = LastApplication.RegistrationNumber.IndexOf("-");
                    string lastNumber = LastApplication.RegistrationNumber[0].ToString();
                    for (int i = 0; i < lastIndex - 1; i++)
                    {
                        lastNumber += LastApplication.RegistrationNumber[i].ToString();
                    }
                    int FinalNumber = int.Parse(lastNumber);
                    RegNum = (FinalNumber + 1).ToString() + "-{";
                }
                RegNum = RegNum +
                newApplication.PostDate.Value.Day +
                "." +
                newApplication.PostDate.Value.Month +
                "." +
                newApplication.PostDate.Value.Year +
                "}";

                newApplication.RegistrationNumber = RegNum;
                newApplication.IsActive = true;
                Context.Applications.Add(newApplication);

                if (Context.SaveChanges() == 0)
                {
                    return "Post unsuccessfull";
                }

            }
            else
            {
                Console.WriteLine("Application has a null value!");
                return "Application has a null value!";
            }

            Console.WriteLine("Post successful");
            return "Post successful";
        }
 public IHttpActionResult updateApplication(int id, Application newApplication)
 {
     return Ok(repository.updateApplication(id, newApplication));
 }
        //UPDATE
        public string updateApplication(int id, Application newApplication)
        {
            if (isIdCorrect(id))
            {
                if (newApplication != null)
                {
                    var ApplicationToUpdate = getApplicationById(id);

                    ApplicationToUpdate.Sender = newApplication.Sender;
                    ApplicationToUpdate.Subject = newApplication.Subject;

                    Context.SaveChanges();
                }
                else
                {
                    Console.WriteLine("Application has a null value!");
                    return "Application has a null value!";
                }

                Console.WriteLine("Update successful");
                return "Update successful";
            }
            else
            {
                Console.WriteLine("Invalid id!!!");
                return "Invalid id!!!";
            }
        }
 public IHttpActionResult postApplication(Application newApplication)
 {
     return Ok(repository.postApplication(newApplication));
 }