public ActionResult ModalPartialDone(int userid)
        {
            ModalPartialDoneViewModel model = new ModalPartialDoneViewModel()
            {
                Id = userid
            };

            //_emailService.SendEmail(new EmailMessage()
            //{
            //    body = "this is a test",
            //    recieverAddress = "*****@*****.**",
            //    recieverName = "Vali Scoican",
            //    subject = "test email"
            //});


            return(View(model));
        }
        public ActionResult ModalPartialDone(ModalPartialDoneViewModel model)
        {
            Request request = db.Requests.Where(m => m.requestId == model.Id).FirstOrDefault();
            List <RequestHistory> requestHistory = db.RequestHistories.Where(m => m.requestId == request.requestId).ToList();



            int?fileresult = null;

            DatabaseConnection.File fileDb = null;
            if (model.File != null && model.File.ContentLength > 0)
            {
                try
                {
                    string path = Path.Combine(Server.MapPath("~/Files"),
                                               Path.GetFileName(model.File.FileName));
                    model.File.SaveAs(path);

                    fileDb = new DatabaseConnection.File
                    {
                        fileName = model.File.FileName,
                        fileType = model.File.ContentType
                    };


                    db.Files.Add(fileDb);
                    db.SaveChanges();
                    fileresult = fileDb.fileId;
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERROR:" + ex.Message.ToString();
                }
            }
            else
            {
                fileresult = null;
            }


            RequestHistory lastRequest = new RequestHistory
            {
                from          = requestHistory.Last().to,
                to            = requestHistory.First().from,
                message       = model.Message,
                data          = DateTime.Now,
                status        = "Done",
                approval      = "0",
                requestId     = request.requestId,
                attachmentsId = fileresult
            };

            db.RequestHistories.Add(lastRequest);
            db.SaveChanges();

            //_emailService.SendEmail(new EmailMessage()
            //{
            //    body = "this is a test",
            //    recieverAddress = "*****@*****.**",
            //    recieverName = "Bogdan Tereanu",
            //    subject = "test email"
            //});

            return(RedirectToAction("Dashboard"));
        }