コード例 #1
0
ファイル: PersetujuanController.cs プロジェクト: kacrut/skpd
        public ActionResult Reject(RejectRequest model)
        {
            var ApprovalPositionID = db.Users.Where(a => a.Username == User.Identity.Name).Select(a => a.PositionID).Single();
            if (ModelState.IsValid)
            {
                if (!ServiceSkpd.isRequestIDExist(model.RequestID))
                {
                    ModelState.AddModelError("", "RequestID tidak ditemukan!");
                }
                else
                {
                    if (ServiceSkpd.isAlreadyApproveOrReject(model.RequestID, ApprovalPositionID, 3))
                    {
                        ModelState.AddModelError("", "Request ini sudah pernah di Tolak oleh anda!");
                    }
                    else if (ServiceSkpd.isAlreadyApproveOrReject(model.RequestID, ApprovalPositionID, 2))
                    {
                        ModelState.AddModelError("", "Request ini sudah di Setujui oleh anda!");
                        ModelState.AddModelError("", "Request ini hanya bisa di batalkan oleh posisi diatas anda!");
                    }
                    else
                    {
                        using (TransactionScope transaction = new TransactionScope())
                        {
                            var FlagCreatedDate = DateTime.Now;

                            Request request = db.Requests.Where(a => a.RequestID == model.RequestID).FirstOrDefault();

                            request.FlagID = 3;
                            request.FlagCreatedDate = FlagCreatedDate;
                            request.RejectedReason = model.RejectedReason;
                            db.Entry(request).State = EntityState.Modified;
                            db.SaveChanges();

                            string hostUrl = Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
                            if (ServiceSkpd.SendEmailRejectToRequesterCcApprover(request, db, MessengerService))
                            {
                                transaction.Complete();
                                return RedirectToAction("SuccessReject");
                            }
                            else
                            {
                                ModelState.AddModelError("", "Gagal proses pengajuan");
                                ModelState.AddModelError("", "Gagal mengirim email");
                                ModelState.AddModelError("", "Pastikan anda sedang terhubung koneksi internet");
                            }
                        }
                    }
                }
            }
            return View(model);
        }
コード例 #2
0
ファイル: PersetujuanController.cs プロジェクト: kacrut/skpd
 public ActionResult Reject(int id)
 {
     RejectRequest rejectreq = new RejectRequest();
     rejectreq.RequestID = db.Requests.Where(a => a.RequestID == id).Select(a => a.RequestID).SingleOrDefault();
     return View(rejectreq);
 }