public ActionResult Create(LeaveRequest leaverequest)
        {
            //this.User
            if (ModelState.IsValid)
            {
                leaverequest.UserID = WebSecurity.GetUserId(User.Identity.Name);
                leaverequest.Status = "P";

                CalculateNumOfDaysController c = new CalculateNumOfDaysController();
                leaverequest.NumOfDays = c.Get(leaverequest.FromDate, leaverequest.ToDate);

                LeaveRequestsController request = new LeaveRequestsController();
                var response = request.PostLeaveRequest(leaverequest);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    return(RedirectToAction("UserLeaveRequests"));
                }
                else
                {
                    ModelState.AddModelError("createError", new Exception(response.Content.ReadAsStringAsync().Result));
                }
            }

            return(View(leaverequest));
        }
        public ActionResult Edit(LeaveRequest leaverequest)
        {
            if (ModelState.IsValid)
            {
                LeaveRequestsController request = new LeaveRequestsController();

                if (leaverequest.AcceptedFromDate.HasValue && leaverequest.AcceptedToDate.HasValue)
                {
                    CalculateNumOfDaysController c = new CalculateNumOfDaysController();
                    leaverequest.AcceptedNumOfDays = c.Get(leaverequest.AcceptedFromDate.Value, leaverequest.AcceptedToDate.Value);
                    leaverequest.Status            = "A";
                    leaverequest.AcceptedBy        = WebSecurity.GetUserId(User.Identity.Name);
                }


                var succ = request.PutLeaveRequest(leaverequest.ID, leaverequest);
                if (succ.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    if (User.IsInRole("HumanResources"))
                    {
                        return(RedirectToAction("PendingLeaveRequests"));
                    }
                    else
                    {
                        return(RedirectToAction("UserLeaveRequests"));
                    }
                }
                else
                {
                    ModelState.AddModelError("putError", succ.Content.ReadAsStringAsync().Result);
                    //ModelState.AddModelError("putError", new Exception("Κάτι πήγε στραβά.. Ελέγξτε τα στοιχεία και δοκιμάστε ξανά.."));
                }
            }

            GetDescriptionController descr = new GetDescriptionController();

            ViewBag.descr = descr;
            return(View(leaverequest));
        }