public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PaymentRequest r = db.PaymentRequests.Find(id);

            if (r == null)
            {
                return(HttpNotFound());
            }
            int    p  = r.AttachedFileName.IndexOf('_');
            string fn = p > 0 ? r.AttachedFileName.Substring(p + 1, r.AttachedFileName.Length - p - 1) : r.AttachedFileName;

            var    q1   = db.RequestHistories.Where(x => x.Request.PaymentRequestId == r.PaymentRequestId).ToList();
            string text = "";

            foreach (var item in q1)
            {
                text += item.WhenPosted.ToString("dd.MM.yyyy HH:mm") + ", " + item.Author.ShortName + ": <br/>";
                text += item.Comments;
                text += "<hr/>";
            }

            PaymentRequestEditModel edit = new PaymentRequestEditModel()
            {
                AttachFileName   = fn, HistoryComments = text,
                type             = r.SumType, PaymentRequestId = r.PaymentRequestId, AgreedPM = r.AgreedPM,
                ProjectName      = r.Project.Name, Sum = r.TimesOrSum, UserName = r.RecipientUser.FullName,
                ProjectCode      = PaymentRequestEditModel.getProjectCode(r.Project.Name),
                ProjectShortName = PaymentRequestEditModel.getProjectShortName(r.Project.Name)
            };

            GenerateProjectsList();

            return(View(edit));
        }
        // GET: RegularPayments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RegularPayment regularPayment = db.RegularPayments.Find(id);

            if (regularPayment == null)
            {
                return(HttpNotFound());
            }
            RegularPaymentEditModel model =
                new RegularPaymentEditModel()
            {
                RegularPaymentId = regularPayment.RegularPaymentId, Sum = regularPayment.Sum, UserName = regularPayment.RecipientUser.FullName,
                PayoutFrom       = regularPayment.PayoutFrom, PayoutTo = regularPayment.PayoutTo,
                ProjectCode      = PaymentRequestEditModel.getProjectCode(regularPayment.Project.Name),
                ProjectShortName = PaymentRequestEditModel.getProjectShortName(regularPayment.Project.Name)
            };

            return(View(model));
        }