Beispiel #1
0
        public ActionResult Create_AddonCategory(AddonCatViewModel newaddoncategory)
        {
            bool success = false;

            if (!ModelState.IsValid)
            {
                return(PartialView(newaddoncategory));
            }

            try
            {
                AddonCategory addoncategory = new AddonCategory()
                {
                    addoncatdesc = newaddoncategory.addoncatdetails
                };
                dbEntities.AddonCategories.Add(addoncategory);
                dbEntities.SaveChanges();

                success = true;
            }
            catch (Exception e)
            {
                var message = e.Message.ToString();

                success = false;
            }


            return(Json(new { success = success }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult CreateReservation(ReservationViewModel bookingreserve)
        {
            if (!ModelState.IsValid)
            {
                return(View(bookingreserve));
            }
            //bool success = false;

            try
            {
                var reservation = new Reservation()
                {
                    c_Id        = bookingreserve.customerId,
                    resDate     = bookingreserve.reserveDate,
                    noofPax     = Convert.ToInt32(bookingreserve.noofperson),
                    occasion    = bookingreserve.occasion,
                    eventVenue  = bookingreserve.eventVenue,
                    reserveStat = false
                };


                dbEntities.Reservations.Add(reservation);
                dbEntities.SaveChanges();

                //success = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            //return View("Index");
            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public ActionResult CreateAddons(AddonsViewModel newAddons)
        {
            var success = false;
            var message = "";

            if (!ModelState.IsValid)
            {
                return(PartialView("CreateAddon", newAddons));
            }

            try
            {
                AddonDetail newaddondetail = new AddonDetail()
                {
                    addoncatId       = newAddons.addoncatId,
                    addondescription = newAddons.AddonsDescription,
                    deptId           = newAddons.deptId,
                    unit             = newAddons.Unit,
                    amount           = newAddons.AddonAmount
                };

                dbEntities.AddonDetails.Add(newaddondetail);
                dbEntities.SaveChanges();

                success = true;
            }
            catch (Exception e)
            {
                message = e.Message.ToString();
                success = false;
            }

            return(Json(new { success = success, message = message }, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult CreateNewDiscount(DiscountCodeDetailsViewModel newdiscountviewmodel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("CreateNewDiscount", newdiscountviewmodel));
            }

            try
            {
                var newdiscount = new Discount()
                {
                    discCode      = newdiscountviewmodel.discCode,
                    disctype      = newdiscountviewmodel.disctype,
                    discount1     = newdiscountviewmodel.discount_amt,
                    discStartdate = newdiscountviewmodel.discStartdate,
                    discEnddate   = newdiscountviewmodel.discEnddate
                };

                _dbEntities.Discounts.Add(newdiscount);
                _dbEntities.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public ActionResult CreateMenus(CourseMenuViewModel courseMenu)
        {
            if (ModelState.IsValid)
            {
                string filename = String.Empty;

                if (courseMenu.UploadImage != null && courseMenu.UploadImage.ContentLength > 0)
                {
                    //filename = Path.GetFileName(courseMenu.UploadImage.FileName);
                    var extension = Path.GetExtension(courseMenu.UploadImage.FileName);
                    var namefile  = Guid.NewGuid().ToString();
                    filename = namefile + extension;

                    var path = Path.Combine(Server.MapPath("~/Content/UploadedImages"), filename);

                    courseMenu.UploadImage.SaveAs(path);
                }

                try
                {
                    var newMenu = new Menu
                    {
                        menuid     = courseMenu.menu_Id,
                        CourserId  = Convert.ToInt32(courseMenu.CourserId),
                        menu_name  = courseMenu.menudesc,
                        deptId     = Convert.ToInt32(courseMenu.deptId),
                        note       = courseMenu.Note,
                        image      = filename,
                        date_added = courseMenu.dateAdded
                    };

                    _dbEntities.Menus.Add(newMenu);
                    _dbEntities.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                //return RedirectToAction("Index");

                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                courseMenu.menu_Id             = Utilities.MenusCode_Generator();
                courseMenu.coursecategory_list = courseMenu.Get_CourseListItems();
                courseMenu.deptincharge_list   = dept.Get_MenuDepartmentInchargeListItems();


                return(View(courseMenu));
            }
        }
Beispiel #6
0
        public ActionResult CreateCourse(CourseCategoryViewModel newcourseCatViewModel)
        {
            if (ModelState.IsValid)
            {
                bool isSuccess = false;

                try
                {
                    var isRecordAlreadyExist = _dbcontext.CourseCategories.Any(x => x.Course.ToLower().Contains(newcourseCatViewModel.Coursename.ToLower()));

                    if (isRecordAlreadyExist)
                    {
                        // ModelState.AddModelError("Course", newcourseCatViewModel.Coursename + " already exist!.");
                        return(Json(
                                   new { success = isSuccess, message = "Unable to save record ;\n Possible for duplicate entry." }, JsonRequestBehavior.AllowGet));
                    }

                    else
                    {
                        var coursecat = new CourseCategory()
                        {
                            CourserId = Convert.ToInt32(newcourseCatViewModel.CourserId),
                            Course    = newcourseCatViewModel.Coursename,
                            Note      = newcourseCatViewModel.Note,
                            Main_Bol  = newcourseCatViewModel.Main_Bol
                        };

                        _dbcontext.CourseCategories.Add(coursecat);
                        _dbcontext.SaveChanges();

                        isSuccess = true;
                        //return RedirectToAction("Index", "Course");

                        return(Json(new { success = isSuccess }, JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception)
                {
                    throw new HttpException(404, "Page Not Found");
                }
            }

            ViewBag.FormTitle = "New Course Category";
            return(View(newcourseCatViewModel));
        }
Beispiel #7
0
        public ActionResult CreateArea(AreaDetailsViewModel new_Area)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_create_areaPartialView", new_Area));
            }

            var recordexist =
                _dbcontext.Areas.Any(x => x.AreaDetails.ToLower().Contains(new_Area.areaDetails.ToLower()));

            if (recordexist)
            {
                return(Json(new { success = false, message = new_Area.areaDetails + "is already in the list" },
                            JsonRequestBehavior.AllowGet));
            }
            else
            {
                try
                {
                    var _area = new_Area.areaDetails.ToUpper();

                    Area newArea = new Area()
                    {
                        aID         = Convert.ToInt32(new_Area.areaId),
                        AreaDetails = _area
                    };

                    _dbcontext.Areas.Add(newArea);
                    _dbcontext.SaveChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }



            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        public ActionResult SavePayment(PaymentsViewModel paymentviewmodel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("Add_PaymentPartialView", paymentviewmodel));
            }

            //  bool success = false;

            var url = "";

            try
            {
                Payment newPayment = new Payment()
                {
                    payNo           = Utilities.Generate_PaymentId(),
                    trn_Id          = paymentviewmodel.transId,
                    dateofPayment   = paymentviewmodel.dateofPayment,
                    particular      = paymentviewmodel.particular,
                    payType         = paymentviewmodel.payType,
                    amtPay          = paymentviewmodel.amtPay,
                    pay_means       = paymentviewmodel.pay_means,
                    checkNo         = paymentviewmodel.checkNo,
                    notes           = paymentviewmodel.notes,
                    p_createdbyUser = User.Identity.GetUserId()
                };

                _dbcontext.Payments.Add(newPayment);
                _dbcontext.SaveChanges();

                url = Url.Action("GetPaymentList", "Payments", new { transId = paymentviewmodel.transId });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(Json(new { success = true, url = url }, JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        public ActionResult BookingRefundEntry(BookingRefundViewModel bookingRefund)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_CreateRefundEntry", bookingRefund));
            }

            var bookrefund = new Refund()
            {
                trn_Id      = bookingRefund.transId,
                rfDate      = bookingRefund.rfDate,
                rf_Reason   = bookingRefund.refundReason,
                rf_Amount   = bookingRefund.refundAmount,
                rfDeduction = bookingRefund.refundDeduction,
                rfNetAmount = bookingRefund.refundNet,
                rf_Stat     = 0
            };

            dbEntities.Refunds.Add(bookrefund);
            dbEntities.SaveChanges();

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        public void SetCancelBooking(int transId)
        {
            var dbcontext = new PegasusEntities();

            var booking = dbcontext.Bookings.FirstOrDefault(x => x.trn_Id == transId);


            try
            {
                if (booking != null)
                {
                    booking.is_cancelled = true;

                    dbcontext.Bookings.Attach(booking);
                    dbcontext.Entry(booking).Property(x => x.is_cancelled).IsModified = true;
                    dbcontext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Beispiel #11
0
        public ActionResult CreateCustomer(CustomerDetailsViewModel newcusViewmodel)
        {
            newcusViewmodel.datereg = Convert.ToDateTime(DateTime.Today);

            bool isSuccess = false;

            if (ModelState.IsValid)
            {
                string _lastname  = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(newcusViewmodel.lastname);
                string _firstname = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(newcusViewmodel.firstname);

                string _middle = string.Empty;

                if (newcusViewmodel.middle != null)
                {
                    _middle = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(newcusViewmodel.middle);
                }
                else
                {
                    _middle = newcusViewmodel.middle;
                }

                string _address = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(newcusViewmodel.address);

                //verify if customer has already record

                var isRecordAlreadyExist = _dbcontext.Customers.Any(x => x.lastname == _lastname && x.firstname == _firstname);

                if (isRecordAlreadyExist)
                {
                    return(Json(
                               new { success = isSuccess, message = "Unable to save record ;\n Possible for duplicate entry." }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    try
                    {
                        var newcustomer = new Customer()
                        {
                            c_Id      = Convert.ToInt32(newcusViewmodel.c_Id),
                            lastname  = _lastname,
                            firstname = _firstname,
                            middle    = _middle,
                            address   = _address,
                            contact1  = newcusViewmodel.contact1,
                            contact2  = newcusViewmodel.contact2,
                            datereg   = newcusViewmodel.datereg,
                            company   = newcusViewmodel.company
                        };

                        _dbcontext.Customers.Add(newcustomer);
                        _dbcontext.SaveChanges();

                        isSuccess = true;

                        return(Json(new { success = isSuccess }, JsonRequestBehavior.AllowGet));
                    }
                    catch (DbEntityValidationException e)
                    {
                        foreach (var eve in e.EntityValidationErrors)
                        {
                            Console.WriteLine(
                                "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                eve.Entry.Entity.GetType().Name, eve.Entry.State);
                            foreach (var ve in eve.ValidationErrors)
                            {
                                Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                                  ve.PropertyName, ve.ErrorMessage);
                            }
                        }


                        throw;
                    }
                }
            }


            ViewBag.FormTitle = "Create New Customer";
            return(View(newcusViewmodel));
        }
Beispiel #12
0
        public ActionResult CreatePackage(PackageViewModel newpackage)
        {
            if (!ModelState.IsValid)
            {
                newpackage.packageNoPax_listitem = pviewmodel.GetPackageNoofPaxListItems();

                return(PartialView("_packages", newpackage));
            }


            string packagename = string.Empty;


            if (!String.IsNullOrEmpty(newpackage.p_descripton))
            {
                packagename = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(newpackage.p_descripton);
            }
            else
            {
                packagename = newpackage.p_descripton;
            }

            var packagedata = new Package
            {
                p_id         = Convert.ToInt32(newpackage.p_id),
                p_type       = newpackage.packagetype,
                p_descripton = packagename,
                p_amountPax  = Convert.ToDecimal(newpackage.p_amountPax),
                p_min        = newpackage.p_min,
                isActive     = true,
                nopax_id     = newpackage.packagenopax_id
            };

            _dbcontext.Packages.Add(packagedata);
            _dbcontext.SaveChanges();

            Utilities.ActiveForm = "newPackagebody";

            Utilities.PackageBodyModel.package_Id   = Convert.ToInt32(packagedata.p_id);
            Utilities.PackageBodyModel.package_name = packagedata.p_descripton;

            var url = Url.Action("Package_Body_Details", "Packages");

            return(Json(new { success = true, url = url }, JsonRequestBehavior.AllowGet));
            //return PartialView("_packagebody", Utilities.PackageBodyModel);
        }