示例#1
0
        public IActionResult Update(int id, long dt_log, int new_status, string Comment)
        {
            try
            {
                using (MUPContext db = new MUPContext())
                {
                    using (var transact = db.Database.BeginTransaction(IsolationLevel.RepeatableRead))
                    {
                        //получаем последнюю запись из лога
                        var rl = db.RequestLogs
                                 .Where(r => r.RequestId == id)
                                 .OrderByDescending(a => a.LogTime)
                                 .First();

                        ////проверяем последняя ли запись
                        if (rl.LogTime.Ticks != dt_log)
                        {
                            throw new Exception("Данные устарели, необходимо обновить!");
                        }

                        if (!StatusUtils.CheckNextStatus(rl.Status, new_status))
                        {
                            throw new Exception(string.Format("Недопустимое изменение статуса заявки '{0}'->'{1}'",
                                                              StatusUtils.GetStatusName(rl.Status), StatusUtils.GetStatusName(new_status)));
                        }

                        //добавление записи
                        db.RequestLogs.Add(new RequestLog
                        {
                            RequestId = id,
                            Status    = new_status,
                            Comment   = Comment,
                            LogTime   = DateTime.Now
                        });

                        db.SaveChanges();
                        transact.Commit();
                    }
                }

                return(Redirect((Url.Action("Update", new { id = id }))));
            }
            catch (Exception e)
            {
                return(View("ErrorUpdate", new ErrorUpdate {
                    message = e.Message, id = id
                }));
            }
        }
示例#2
0
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
            BeginContext(0, 7, true);
            WriteLiteral("<div>\r\n");
            EndContext();
#line 2 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"

            RequestLog LastReq        = Model.requests[0];
            RequestLog FirstReq       = Model.requests[Model.requests.Length - 1];
            int[]      AccessStatuses = StatusUtils.GetAccessStatus(LastReq.Status);



#line default
#line hidden
            BeginContext(223, 648, true);
            WriteLiteral(@"
    <script type=""text/javascript"">
        $(document).ready(function () {
                       

            $("":submit"").click(function () {
                const status = $(this).attr(""data-status"");
                    $(""#new_status"").val(status);
            });


            $(""#Comment"").on(""input"", function () {
                let txt = $(this).val()
                    .trim();

                const empty = (txt == """");

                $("":submit"").prop(""disabled"", empty);
            });    
        });
    </script>

    <div>
        <ol class=""breadcrumb"">
            <li class=""breadcrumb-item"">");
            EndContext();
            BeginContext(872, 47, false);
#line 32 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
            Write(Html.ActionLink("Список заявок", "Index", "Home"));

#line default
#line hidden
            EndContext();
            BeginContext(919, 56, true);
            WriteLiteral("</li>\r\n            <li class=\"breadcrumb-item\">Заявка № ");
            EndContext();
            BeginContext(976, 17, false);
#line 33 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
            Write(LastReq.RequestId);

#line default
#line hidden
            EndContext();
            BeginContext(993, 45, true);
            WriteLiteral("</li>\r\n        </ol>\r\n    </div>\r\n    <div>\r\n");
            EndContext();
#line 37 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
            using (Html.BeginForm("Update", "Request", FormMethod.Post))
            {
#line default
#line hidden
                BeginContext(1133, 44, false);
#line 39 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(Html.Hidden("dt_log", LastReq.LogTime.Ticks));

#line default
#line hidden
                EndContext();
                BeginContext(1189, 46, true);
                WriteLiteral("            <div>\r\n                <h5>Статус:");
                EndContext();
                BeginContext(1236, 41, false);
#line 41 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(StatusUtils.GetStatusName(LastReq.Status));

#line default
#line hidden
                EndContext();
                BeginContext(1277, 37, true);
                WriteLiteral("</h5>\r\n                <h5>Обновлена:");
                EndContext();
                BeginContext(1315, 51, false);
#line 42 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(LastReq.LogTime.ToString("dd-MMMM-yyyy , HH:mm:ss"));

#line default
#line hidden
                EndContext();
                BeginContext(1366, 75, true);
                WriteLiteral("</h5>\r\n                <div class=\"alert alert-info\">\r\n                    ");
                EndContext();
                BeginContext(1442, 16, false);
#line 44 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(FirstReq.Comment);

#line default
#line hidden
                EndContext();
                BeginContext(1458, 46, true);
                WriteLiteral("\r\n                </div>\r\n            </div>\r\n");
                EndContext();
#line 49 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                if (AccessStatuses.Length > 0)
                {
#line default
#line hidden
                    BeginContext(1566, 177, true);
                    WriteLiteral("                <div>Комментарий</div>\r\n                <div>\r\n                    <textarea id=\"Comment\" name=\"Comment\" cols=\"50\" rows=\"3\"></textarea>\r\n                </div>\r\n");
                    EndContext();
#line 55 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                }

#line default
#line hidden
                BeginContext(1760, 35, true);
                WriteLiteral("            <div>\r\n                ");
                EndContext();
                BeginContext(1796, 25, false);
#line 58 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(Html.Hidden("new_status"));

#line default
#line hidden
                EndContext();
                BeginContext(1821, 20, true);
                WriteLiteral("\r\n                \r\n");
                EndContext();
#line 60 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                foreach (int sa in AccessStatuses)
                {
#line default
#line hidden
                    BeginContext(1913, 40, true);
                    WriteLiteral("                    <input type=\"submit\"");
                    EndContext();
                    BeginWriteAttribute("value", " value=\"", 1953, "\"", 1991, 1);
#line 62 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                    WriteAttributeValue("", 1961, StatusUtils.GetStatusName(sa), 1961, 30, false);

#line default
#line hidden
                    EndWriteAttribute();
                    BeginContext(1992, 14, true);
                    WriteLiteral(" data-status=\"");
                    EndContext();
                    BeginContext(2007, 2, false);
#line 62 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                    Write(sa);

#line default
#line hidden
                    EndContext();
                    BeginContext(2009, 39, true);
                    WriteLiteral("\"  class=\"btn btn-primary\" disabled/>\r\n");
                    EndContext();
#line 63 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                }

#line default
#line hidden
                BeginContext(2067, 19, true);
                WriteLiteral("           </div>\r\n");
                EndContext();
#line 65 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
            }

#line default
#line hidden
            BeginContext(2097, 444, true);
            WriteLiteral(@"    </div>
    <div>
        <h5>История движения заявки</h5>
    </div>
    <div>
        <table class=""table table-sm table-bordered""  style=""width:60%"">
            <thead>
                <tr>
                    <th scope=""col"">Дата , Время</th>
                    <th scope=""col"">Статус</th>
                    <th scope=""col"">Коментарий</th>
                </tr>                
            </thead>
            <tbody>
");
            EndContext();
#line 80 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
            foreach (RequestLog rl in Model.requests)
            {
#line default
#line hidden
                BeginContext(2620, 84, true);
                WriteLiteral("                    <tr>\r\n                        <td>\r\n                            ");
                EndContext();
                BeginContext(2705, 44, false);
#line 84 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(rl.LogTime.ToString("dd/MM/yyyy , HH:mm:ss"));

#line default
#line hidden
                EndContext();
                BeginContext(2749, 91, true);
                WriteLiteral("\r\n                        </td>\r\n                        <th>\r\n                            ");
                EndContext();
                BeginContext(2841, 36, false);
#line 87 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(StatusUtils.GetStatusName(rl.Status));

#line default
#line hidden
                EndContext();
                BeginContext(2877, 91, true);
                WriteLiteral("\r\n                        </th>\r\n                        <td>\r\n                            ");
                EndContext();
                BeginContext(2969, 10, false);
#line 90 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
                Write(rl.Comment);

#line default
#line hidden
                EndContext();
                BeginContext(2979, 60, true);
                WriteLiteral("\r\n                        </td>\r\n                    </tr>\r\n");
                EndContext();
#line 93 "C:\Users\RTS_NB\source\repos\MUP_test\MUP_test\Views\Request\Update.cshtml"
            }

#line default
#line hidden
            BeginContext(3058, 62, true);
            WriteLiteral("            </tbody>\r\n        </table>\r\n    </div>\r\n</div>\r\n\r\n");
            EndContext();
        }