Пример #1
0
        public static bool Ubah(VMApplicant paramModel)
        {
            try
            {
                using (var db = new Model1())
                {
                    TB_Applicant a = db.TB_Applicant.Where(x => x.ID == paramModel.ID).FirstOrDefault();

                    if (a != null)
                    {
                        a.Name           = paramModel.Name;
                        a.Contact_Number = paramModel.Contact_Number;
                        a.Email          = paramModel.Email;
                        a.Date_Of_Birth  = paramModel.Date_Of_Birth;
                        a.Address        = paramModel.Address;
                        a.Major          = paramModel.Major;
                        a.Question       = paramModel.Question;
                        a.Modified_By    = paramModel.Modified_By;
                        a.Modified_On    = paramModel.Modified_On;

                        db.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
            }
            return(false);
        }
Пример #2
0
        public static bool savedata(VMApplicant Applicant)
        {
            try
            {
                using (Model1 db = new Model1())
                {
                    TB_Applicant data = new TB_Applicant();
                    data.ID             = Applicant.ID;
                    data.Name           = Applicant.Name;
                    data.Email          = Applicant.Email;
                    data.Contact_Number = Applicant.Contact_Number;
                    data.Date_Of_Birth  = Applicant.Date_Of_Birth;
                    data.Address        = Applicant.Address;
                    data.Major          = Applicant.Major;
                    data.Question       = Applicant.Question;
                    data.Is_Delete      = false;
                    data.Created_By     = "System";
                    data.Created_On     = DateTime.Now;

                    db.TB_Applicant.Add(data);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Пример #3
0
        public static VMApplicant GetDetailsById(long paramID)
        {
            VMApplicant result = new VMApplicant();

            using (var db = new Model1())
            {
                var query = from a in db.TB_Applicant
                            where a.ID == paramID
                            select new VMApplicant
                {
                    ID             = a.ID,
                    Name           = a.Name,
                    Contact_Number = a.Contact_Number,
                    Email          = a.Email,
                    Date_Of_Birth  = a.Date_Of_Birth,
                    Address        = a.Address,
                    Major          = a.Major,
                    Question       = a.Question,
                    Created_By     = a.Created_By,
                    Created_On     = a.Created_On,
                    Modified_By    = a.Modified_By,
                    Modified_On    = a.Modified_On,
                    Is_Delete      = a.Is_Delete
                };
                result = query.FirstOrDefault();
            }
            return(result);
        }
Пример #4
0
        public static VMApplicant GetDataById(int Id)
        {
            VMApplicant result = new VMApplicant();

            using (var db = new Model1())
            {
                var data = from x in db.TB_Applicant
                           where x.ID == Id
                           select new VMApplicant
                {
                    ID             = x.ID,
                    Name           = x.Name,
                    Email          = x.Email,
                    Address        = x.Address,
                    Contact_Number = x.Contact_Number,
                    Date_Of_Birth  = x.Date_Of_Birth,
                    Major          = x.Major,
                    Question       = x.Question,
                    Is_Delete      = x.Is_Delete,
                    Created_By     = "System",
                    Created_On     = DateTime.Now,
                    Modified_By    = "System",
                    Modified_On    = DateTime.Now
                };
                result = data.FirstOrDefault();
            }
            return(result);
        }
Пример #5
0
        public ActionResult Edit(VMApplicant paramModel)
        {
            bool result = false;

            if (result == true)
            {
                return(Json(new { message = "Berhasil" }, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index", "Daftar");
            }
            else
            {
                return(Json(new { message = "Gagal" }, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index", "Applicant");
            }
        }
Пример #6
0
        public ActionResult Create(VMApplicant Applicant)
        {
            Boolean result = RepoApplicant.savedata(Applicant);

            if (result == true)
            {
                return(Json(new { message = "Berhasil" }, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index", "Nasabah");
            }
            else
            {
                return(Json(new { message = "Gagal", data = result }, JsonRequestBehavior.AllowGet));
                //return RedirectToAction("Index", "Applicant");
            }
        }
Пример #7
0
        public IActionResult Review(int id)
        {
            VMApplicant vmApplicant = new VMApplicant
            {
                Applicant     = new Applicant(),
                ExpenseReport = new ExpenseReport()
            };

            vmApplicant.Applicant     = _unitOfWork.Applicant.Get(id);
            vmApplicant.ExpenseReport = _unitOfWork.ExpenseReport.Get(_unitOfWork.Applicant.Get(id).ExpenseSheetId.GetValueOrDefault());

            if (vmApplicant.Applicant == null)
            {
                return(NotFound());
            }

            return(View(vmApplicant));
        }
        public IActionResult Upsert(VMApplicant vmApplicant)
        {
            /* vmApplicant.Applicant.ExpenseSheetId = vmApplicant.ExpenseReport.ExpenseReportKey; */

            if (ModelState.IsValid)
            {
                if (vmApplicant.Applicant.ApplicantKey == 0)
                {
                    _unitOfWork.ExpenseReport.Add(vmApplicant.ExpenseReport);
                    _unitOfWork.Applicant.Add(vmApplicant.Applicant);
                    _unitOfWork.Save();
                }
                else
                {
                    _unitOfWork.ExpenseReport.Update(vmApplicant.ExpenseReport);
                    _unitOfWork.Applicant.Update(vmApplicant.Applicant);
                }
                _unitOfWork.Save();
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vmApplicant));
        }
        public IActionResult Upsert(int?id)
        {
            VMApplicant vmApplicant = new VMApplicant
            {
                Applicant     = new Applicant(),
                ExpenseReport = new ExpenseReport()
            };

            if (id == null)

            {
                /*  vmApplicant.Applicant.ApplicationStatus = SD.Pending; */
                return(View(vmApplicant));
            }
            vmApplicant.Applicant     = _unitOfWork.Applicant.Get(id.GetValueOrDefault());
            vmApplicant.ExpenseReport = _unitOfWork.ExpenseReport.Get(_unitOfWork.Applicant.Get(id.GetValueOrDefault()).ExpenseSheetId.GetValueOrDefault());
            if (vmApplicant.Applicant == null)
            {
                return(NotFound());
            }
            return(View(vmApplicant));
        }