Esempio n. 1
0
 public ActionResult RequestInProgram(int id)
 {
     RequestInProgramDTO requestinprogram = new RequestInProgramDTO();
     requestinprogram.RequestID = id;
     return View(requestinprogram);
 }
Esempio n. 2
0
        public ActionResult RequestInProgram(RequestInProgramDTO model)
        {
            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {

                    var ApprovalPositionID = db.Users.Where(a => a.Username == User.Identity.Name).Select(a => a.PositionID).Single();
                    //var ApprovalPositionInProgram = db.vwPositionInPrograms
                    //                .Where(a => a.DivisionID == model.DivisionID && a.KdProg==model.BudgetID)
                    //                .Select(a => a.PositionID).SingleOrDefault();
                    DateTime DateTimeNow = DateTime.Now;

                    //UPDATE REQUEST
                    Request request = db.Requests.Include("RequestInTransports").Where(a => a.RequestID == model.RequestID).First();
                    RequestInProgram requestinprogram = new RequestInProgram();
                    string hostUrl = Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);

                    //MY BUDGET
                    if (model.sendirilain != 2)
                    {
                        //APPROVED
                        request.FlagID = 2;
                        request.FlagCreatedDate = DateTimeNow;
                        db.Entry(request).State = EntityState.Modified;
                        db.SaveChanges();

                        if (ServiceSkpd.SendEmailResultToRequesterCcApprover(request, db, MessengerService))
                        {
                            //APPROVE REQUESTINPROGRAM
                            requestinprogram.RequestID = model.RequestID;
                            requestinprogram.ProgramID = model.ProgramID;

                            db.RequestInPrograms.Add(requestinprogram);
                            db.SaveChanges();

                            request.FlagID = 7;
                            request.ApprovalPositionID = 194;
                            request.FlagCreatedDate = DateTimeNow;
                            db.Entry(request).State = EntityState.Modified;
                            db.SaveChanges();

                            //if (request.ApprovalPositionID == ApprovalPositionID)
                            //{
                            //    request.FlagID = 8;
                            //    request.FlagCreatedDate = DateTime.Now;
                            //    db.Entry(request).State = EntityState.Modified;
                            //    db.SaveChanges();
                            //}

                            transaction.Complete();
                            this.HttpContext.Session["RequestID"] = requestinprogram.RequestID;
                            return RedirectToAction("SuccessAddBudget");
                        }
                        else
                        {
                            ModelState.AddModelError("", "Gagal proses pengajuan");
                            ModelState.AddModelError("", "Gagal mengirim email");
                            ModelState.AddModelError("", "Pastikan anda sedang terhubung koneksi internet");
                        }
                    }
                    //BUDGET ANOTHER DIVISION
                    else
                    {
                        //APPROVED
                        request.FlagID = 2;
                        request.FlagCreatedDate = DateTimeNow;
                        db.Entry(request).State = EntityState.Modified;
                        db.SaveChanges();

                        if (ServiceSkpd.SendEmailResultToRequesterCcApprover(request, db, MessengerService))
                        {
                            var AssignIDForBudget = db.vwPositionInPrograms.Where(a => a.UnitID == model.UnitID).Select(a => a.PositionID).FirstOrDefault();
                            request.FlagID = 9;
                            request.FlagCreatedDate = DateTimeNow;
                            request.ApprovalPositionID = AssignIDForBudget;
                            db.Entry(request).State = EntityState.Modified;
                            db.SaveChanges();

                            if (ServiceSkpd.SendEmailRequestBudgetToDivisionFromRequester(hostUrl, request, db, MessengerService))
                            {
                                transaction.Complete();
                                return RedirectToAction("SuccessSendRequestBudget");
                            }
                            else
                            {
                                ModelState.AddModelError("", "Gagal proses pengajuan");
                                ModelState.AddModelError("", "Gagal mengirim email");
                                ModelState.AddModelError("", "Pastikan anda sedang terhubung koneksi internet");
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("", "Gagal proses pengajuan");
                            ModelState.AddModelError("", "Gagal mengirim email");
                            ModelState.AddModelError("", "Pastikan anda sedang terhubung koneksi internet");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.InnerException);
            }
            return View(model);
        }
Esempio n. 3
0
 public ActionResult RequestInProgram(string tiket)
 {
     string QueryStringModuleDecrypt = QueryStringModule.Decrypt(tiket);
     NameValueCollection NameValue = HttpUtility.ParseQueryString(QueryStringModuleDecrypt);
     var RequestID = NameValue["RequestID"];
     var UserName = NameValue["UserName"];
     int intRequestID = Convert.ToInt16(RequestID);
     var ApprovalPositionID = db.Requests.Where(a => a.RequestID == intRequestID).Select(a => a.ApprovalPositionID).SingleOrDefault();
     var ApprovalDivisionID = db.vwUserProfiles.Where(a => a.PositionID == ApprovalPositionID).Select(a => a.DivisionID).SingleOrDefault();
     RequestInProgramDTO requestinprogram = new RequestInProgramDTO();
     requestinprogram.RequestID = intRequestID;
     //requestinprogram.ApproverPositionID = ApprovalPositionID;
     //requestinprogram.DivisionID = ApprovalDivisionID;
     return View(requestinprogram);
 }