Exemplo n.º 1
0
        public static decimal GetHargaPeserta(EPriceLevelCategory priceCategory)
        {
            decimal result = 250000;

            switch (priceCategory)
            {
            case EPriceLevelCategory.Dosen:
                result = 250000;
                break;

            case EPriceLevelCategory.MahasiswaPascaSarjana:
                result = 200000;
                break;

            case EPriceLevelCategory.MahasiswaS1:
                result = 100000;
                break;

            default: break;
            }

            return(result);
        }
Exemplo n.º 2
0
        public static decimal GetHargaMakalah(EPriceLevelCategory priceCategory, bool moreThanOne)
        {
            decimal result = 350000;

            if (moreThanOne)
            {
                return(250000);
            }

            switch (priceCategory)
            {
            case EPriceLevelCategory.Dosen:
                result = 350000;
                break;

            case EPriceLevelCategory.MahasiswaPascaSarjana:
                result = 300000;
                break;

            default: break;
            }

            return(result);
        }
Exemplo n.º 3
0
        public ActionResult KonfirmasiPembayaranMakalah(PaymentConfirmationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.PriceLevelCategory < 0 || model.PriceLevelCategory > 1)
            {
                ModelState.AddModelError("", "Nilai untuk kategori harga salah.");
                return(View(model));
            }

            EPriceLevelCategory priceLevelCategory = (EPriceLevelCategory)model.PriceLevelCategory;

            string userId = User.Identity.GetUserId();

            int paperAlreadyPaidCount = (from m in db.Makalah
                                         where m.userId == userId &&
                                         m.PaperPaymentStatus == EPaperPaymentStatus.Diterima
                                         select m).Count();

            decimal makalahPrice = GlobalData.GetHargaMakalah(priceLevelCategory, paperAlreadyPaidCount > 0);

            if (model.TransferAmount < makalahPrice)
            {
                ModelState.AddModelError("", string.Format("Jumlah yang harus ditransfer sebesar {0:C2}", makalahPrice));

                //model.TransferAmount = makalahPrice;

                return(View(model));
            }

            bool includeIdentityFile = false;

            if (priceLevelCategory != EPriceLevelCategory.Dosen)
            {
                if (model.AttachmentFileUpload == null)
                {
                    ModelState.AddModelError("", "Untuk mahasiswa pasca sarjana dan mahasiswa S1 harus melampirkan bukti sebagai mahasiswa aktif");
                    return(View(model));
                }

                if (model.AttachmentFileUpload.ContentLength > MaxUploadFileSize)
                {
                    ModelState.AddModelError("", string.Format("Maksimal ukuran file identitas tambahan adalah {0} bytes (1 MB)", MaxUploadFileSize));

                    return(View(model));
                }

                if (model.AttachmentFileUpload.ContentType.Substring(0, 5) != "image")
                {
                    ModelState.AddModelError("", "Format file identitas tambahan tidak valid.");

                    return(View(model));
                }

                includeIdentityFile = true;
            }
            else
            {
                if (model.AttachmentFileUpload != null)
                {
                    model.AttachmentFileUpload = null;
                }
            }

            if (model.TransferSlipFileUpload == null || model.TransferSlipFileUpload.ContentLength == 0)
            {
                ModelState.AddModelError("", "Belum ada bukti transfer yang diunggah.");

                return(View(model));
            }

            if (model.TransferSlipFileUpload.ContentLength > MaxUploadFileSize)
            {
                ModelState.AddModelError("", string.Format("Maksimal ukuran file bukti transfer adalah {0} bytes (1 MB)", MaxUploadFileSize));

                return(View(model));
            }

            if (model.TransferSlipFileUpload.ContentType.Substring(0, 5) != "image")
            {
                ModelState.AddModelError("", "Format file bukti transfer tidak valid.");

                return(View(model));
            }

            Makalah makalah = db.Makalah.Find(model.MakalahId);

            if (makalah == null)
            {
                return(HttpNotFound());
            }

            try
            {
                string imageTransferFileName = GetFileNameFromDateTime(DateTime.UtcNow, "Ppr", ".jpg");
                string paymentPath           = Server.MapPath(GlobalData.PaperPaymentConfirmationImageFileSavePath);

                if (!Directory.Exists(paymentPath))
                {
                    Directory.CreateDirectory(paymentPath);
                }

                string paymentSaveFilePath = Path.Combine(paymentPath, imageTransferFileName);
                model.TransferSlipFileUpload.SaveAs(paymentSaveFilePath);

                PembayaranMakalah pembayaranMakalah = new PembayaranMakalah()
                {
                    MakalahId            = model.MakalahId,
                    PriceLevelCategory   = priceLevelCategory,
                    BankSenderName       = model.BankSenderName,
                    TransferAmount       = model.TransferAmount,
                    SlipFileName         = imageTransferFileName,
                    IsAdminConfirmed     = false,
                    ConfirmationResult   = false,
                    ConfirmationMessage  = string.Empty,
                    UserConfirmationDate = DateTime.UtcNow,
                    Description          = model.Description
                };

                if (includeIdentityFile)
                {
                    string identityFileName = GetFileNameFromDateTime(DateTime.UtcNow, "Id", ".jpg");
                    string identityPath     = Server.MapPath(GlobalData.IdentityPaymentConfirmationImageFileSavePath);

                    if (!Directory.Exists(identityPath))
                    {
                        Directory.CreateDirectory(identityPath);
                    }

                    string identitySaveFilePath = Path.Combine(identityPath, identityFileName);
                    model.AttachmentFileUpload.SaveAs(identitySaveFilePath);
                    pembayaranMakalah.AttachmentFileName = identityFileName;
                }

                db.PembayaranMakalah.Add(pembayaranMakalah);

                makalah.PaperPaymentStatus         = EPaperPaymentStatus.KonfirmasiPembayaran;
                makalah.PaperPaymentConfirmMessage = GlobalData.GetPaperPaymentStatusMessage(EPaperPaymentStatus.KonfirmasiPembayaran);

                db.Entry(makalah).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                string informationMessage = makalah.PaperPaymentConfirmMessage;
                return(RedirectToAction("Index", new { InformationMessage = informationMessage }));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;

                return(View("Error"));
            }
        }
Exemplo n.º 4
0
        public ActionResult KonfirmasiPembayaranPeserta(PaymentConfirmationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.PriceLevelCategory < 0 || model.PriceLevelCategory > 2)
            {
                ModelState.AddModelError("", "Nilai untuk kategori harga salah.");
                return(View(model));
            }

            EPriceLevelCategory priceLevelCategory = (EPriceLevelCategory)model.PriceLevelCategory;

            decimal pesertaPrice = GlobalData.GetHargaPeserta(priceLevelCategory);

            if (model.TransferAmount < pesertaPrice)
            {
                ModelState.AddModelError("", string.Format("Jumlah yang harus ditransfer sebesar {0:C2}", pesertaPrice));

                //model.TransferAmount = pesertaPrice;

                return(View(model));
            }

            bool includeIdentityFile = false;

            if (priceLevelCategory != EPriceLevelCategory.Dosen)
            {
                if (model.AttachmentFileUpload == null)
                {
                    ModelState.AddModelError("", "Untuk mahasiswa pasca sarjana dan mahasiswa S1 harus melampirkan bukti sebagai mahasiswa aktif");
                    return(View(model));
                }

                if (model.AttachmentFileUpload.ContentLength > MaxUploadFileSize)
                {
                    ModelState.AddModelError("", string.Format("Maksimal ukuran file identitas tambahan adalah {0} bytes (1 MB)", MaxUploadFileSize));

                    return(View(model));
                }

                if (model.AttachmentFileUpload.ContentType.Substring(0, 5) != "image")
                {
                    ModelState.AddModelError("", "Format file identitas tambahan tidak valid.");

                    return(View(model));
                }

                includeIdentityFile = true;
            }
            else
            {
                if (model.AttachmentFileUpload != null)
                {
                    model.AttachmentFileUpload = null;
                }
            }

            if (model.TransferSlipFileUpload == null || model.TransferSlipFileUpload.ContentLength == 0)
            {
                ModelState.AddModelError("", "Belum ada bukti transfer yang diunggah.");

                return(View(model));
            }

            if (model.TransferSlipFileUpload.ContentLength > MaxUploadFileSize)
            {
                ModelState.AddModelError("", string.Format("Maksimal ukuran file bukti transfer adalah {0} bytes (1 MB)", MaxUploadFileSize));

                return(View(model));
            }

            if (model.TransferSlipFileUpload.ContentType.Substring(0, 5) != "image")
            {
                ModelState.AddModelError("", "Format file bukti transfer tidak valid.");

                return(View(model));
            }

            ApplicationUser currentUser = UserManager.FindById(User.Identity.GetUserId());

            ViewBag.UserFullName = GetUserCompleteName(currentUser);

            try
            {
                string participantFileName    = GetFileNameFromDateTime(DateTime.UtcNow, "Peserta", ".jpg");
                string participantPaymentPath = Server.MapPath(GlobalData.ParticipantPaymentConfirmationImageFileSavePath);

                if (!Directory.Exists(participantPaymentPath))
                {
                    Directory.CreateDirectory(participantPaymentPath);
                }

                string participantSaveFilePath = Path.Combine(participantPaymentPath, participantFileName);
                model.TransferSlipFileUpload.SaveAs(participantSaveFilePath);

                PembayaranPeserta pembayaranPeserta = new PembayaranPeserta()
                {
                    UserId               = User.Identity.GetUserId(),
                    PriceLevelCategory   = priceLevelCategory,
                    BankSenderName       = model.BankSenderName,
                    TransferAmount       = model.TransferAmount,
                    SlipFileName         = participantFileName,
                    IsAdminConfirmed     = false,
                    ConfirmationResult   = false,
                    ConfirmationMessage  = string.Empty,
                    UserConfirmationDate = DateTime.UtcNow,
                    Description          = model.Description
                };

                if (includeIdentityFile)
                {
                    string identityFileName = GetFileNameFromDateTime(DateTime.UtcNow, "Identitas", ".jpg");
                    string identityPath     = Server.MapPath(GlobalData.IdentityPaymentConfirmationImageFileSavePath);

                    if (!Directory.Exists(identityPath))
                    {
                        Directory.CreateDirectory(identityPath);
                    }

                    string identitySaveFilePath = Path.Combine(identityPath, identityFileName);
                    model.AttachmentFileUpload.SaveAs(identitySaveFilePath);
                    pembayaranPeserta.AttachmentFileName = identityFileName;
                }

                db.PembayaranPeserta.Add(pembayaranPeserta);

                currentUser.ParticipantPaymentStatus         = EParticipantPaymentStatus.KonfirmasiPembayaran;
                currentUser.ParticipantPaymentConfirmMessage = GlobalData.GetParticipantPaymentStatusMessage(EParticipantPaymentStatus.KonfirmasiPembayaran);

                db.Entry(currentUser).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                //ViewBag.UserFullName = GetUserCompleteName(currentUser);
                //UserProfileViewModel userProfileViewModel = GetUserProfileViewModel(currentUser);

                //if (string.IsNullOrEmpty(userProfileViewModel.ParticipantPaymentConfirmMessage))
                //{
                //    userProfileViewModel.ParticipantPaymentConfirmMessage = GlobalData.GetParticipantPaymentStatusMessage(userProfileViewModel.ParticipantPaymentStatus);
                //}

                //ViewBag.ParticipantStatusMessage = userProfileViewModel.ParticipantPaymentConfirmMessage;

                string informationMessage = "Terima kasih. Konfirmasi pembayaran peserta anda telah terkirim.";

                return(RedirectToAction("UserProfile", new { InformationMessage = informationMessage }));

                //return View("UserProfile", userProfileViewModel);
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;

                return(View("Error"));
            }
        }