コード例 #1
0
        public ActionResult DeleteMember(int id)
        {
            MemberViewModel vm = new MemberViewModel();

            tblMembership tb  = _db.tblMemberships.Where(m => m.MembershipId == id).FirstOrDefault();
            tblUser       tbu = _db.tblUsers.Where(u => u.UserId == tb.UserId).FirstOrDefault();

            vm.MemberId         = tb.MembershipId;
            vm.UserId           = tbu.UserId;;
            vm.Fullname         = tbu.Fullname;
            vm.Email            = tbu.Email;
            vm.Photo            = tbu.Photo;
            vm.Phone            = tbu.Phone;
            vm.Gender           = tbu.Gender;
            vm.MembershipTypeId = tb.MembershipId;
            vm.Fees             = tb.Fees;
            vm.RegDate          = tb.RegDate;
            vm.ShiftId          = tb.ShiftId;

            string regdate = DateTime.Now.ToString("MM/dd/yyyy");

            vm.RegDate = Convert.ToDateTime(regdate);



            ViewBag.Role = _db.Roles.ToList();

            ViewBag.Shift = _db.tblShifts.ToList();

            ViewBag.MembershipType = _db.tblMembershipTypes.ToList();
            return(View(vm));
        }
コード例 #2
0
        public ActionResult Add()
        {
            List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

            var users = db.tblUsers.ToList();

            foreach (var item in users)
            {
                tblMembership tbm = db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                if (tbm != null)
                {
                    lstmemvm.Add(new MemberViewModel()
                    {
                        MemberId = tbm.MembershipId, Fullname = item.Fullname
                    });
                }
            }
            ViewBag.Fullname = lstmemvm;
            AttendanceViewModel atvm = new AttendanceViewModel();
            string todate            = DateTime.Now.ToString("MM/dd/yyyy");

            atvm.AttendanceDate = Convert.ToDateTime(todate);

            return(View(atvm));
        }
コード例 #3
0
        public ActionResult Payment(PaymentViewModel pvm)
        {
            tblPayment tb = new tblPayment();

            tb.MemberId    = pvm.MemberId;
            tb.PaidAmount  = pvm.PaidAmount;
            tb.PaymentDate = pvm.PaymentDate;
            _db.tblPayments.Add(tb);
            _db.SaveChanges();
            ViewBag.Message = "Payment Done Successfully";

            List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

            var users = _db.tblUsers.ToList();

            foreach (var item in users)
            {
                tblMembership tbm = _db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                if (tbm != null)
                {
                    lstmemvm.Add(new MemberViewModel()
                    {
                        MemberId = tbm.MembershipId, Fullname = item.Fullname
                    });
                }
            }
            ViewBag.Fullname = lstmemvm;
            return(View());
        }
コード例 #4
0
        public ActionResult DeleteMember_Post(int id)
        {
            MemberViewModel vm = new MemberViewModel();

            tblMembership tb = _db.tblMemberships.Where(m => m.MembershipId == id).FirstOrDefault();

            _db.tblMemberships.Remove(tb);
            _db.SaveChanges();
            return(RedirectToAction("Index", "Member"));
        }
コード例 #5
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblMembership tblMemberships = _db.tblMemberships.Find(id);

            if (tblMemberships == null)
            {
                return(HttpNotFound());
            }
            return(View(tblMemberships));
        }
コード例 #6
0
        public ActionResult Index()
        {
            List <MeasurementViewModel> lstmvm = new List <MeasurementViewModel>();
            var measures = db.tblMeasurements.ToList();

            foreach (var item in measures)
            {
                tblMembership tb  = db.tblMemberships.Where(m => m.MembershipId == item.MemberId).FirstOrDefault();
                tblUser       tbu = db.tblUsers.Where(k => k.UserId == tb.UserId).FirstOrDefault();
                lstmvm.Add(new MeasurementViewModel()
                {
                    MeasurementId = item.MeasurementId, Fullname = tbu.Fullname, MemberId = item.MemberId, Weight = item.Weight, Chest = item.Chest, Weist = item.Weist, Hip = item.Hip, Thigh = item.Thigh, Bicep = item.Bicep, Forearm = item.Forearm, MeasurementDate = item.MeasurementDate
                });
            }
            return(View(lstmvm));
        }
コード例 #7
0
        // POST: api/membership
        public IHttpActionResult Post([FromBody] MembershipViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    var errMessage = string.Join(", ", ModelState.Values.SelectMany(v => v.Errors).Select(x => x.ErrorMessage));
                    return(Ok(new { status = false, data = "", message = errMessage }));
                }

                var isAny = _db.tblMemberships.Any(d => d.Title.ToLower() == model.Title.ToLower());
                if (isAny)
                {
                    return(Ok(new { status = false, data = "", message = "please try another name." }));
                }

                var membership = new tblMembership()
                {
                    Created          = DateTime.Now.ToUniversalTime(),
                    Description      = model.Description,
                    IsActive         = model.IsActive,
                    Title            = model.Title,
                    Benifits         = model.Benifits,
                    IsUnlimited      = model.IsUnlimited,
                    Price            = model.Price,
                    TotalAppointment = model.TotalAppointment,
                    TotalCustomer    = model.TotalCustomer,
                    TotalEmployee    = model.TotalEmployee,
                    TotalLocation    = model.TotalLocation,
                    TotalOffers      = model.TotalLocation,
                    AdministratorId  = model.AdministratorId
                };
                _db.tblMemberships.Add(membership);
                var response = _db.SaveChanges();

                if (response > 0)
                {
                    return(Ok(new { status = true, data = membership, message = "success" }));
                }
                return(Ok(new { status = false, data = "", message = "failed" }));
            }
            catch (Exception ex)
            {
                return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
            }
        }
コード例 #8
0
        public ActionResult ViewWorkout()
        {
            int           userid = Convert.ToInt32(Session["userid"].ToString());
            tblMembership tbm    = _db.tblMemberships.Where(m => m.UserId == userid).FirstOrDefault();

            List <WorkoutViewModel> lstworkout = new List <WorkoutViewModel>();

            var works = _db.tblWorkouts.OrderByDescending(u => u.WorkoutId).Where(m => m.MemberId == tbm.MembershipId).Take(6);

            foreach (var item in works)
            {
                lstworkout.Add(new WorkoutViewModel()
                {
                    MemberId = item.MemberId, WorkoutDays = item.WorkoutDays, Description = item.Description
                });
            }
            return(View(lstworkout));
        }
コード例 #9
0
        public ActionResult ViewAttendance()
        {
            int           userid = Convert.ToInt32(Session["userid"].ToString());
            tblMembership tbm    = _db.tblMemberships.Where(m => m.UserId == userid).FirstOrDefault();


            List <AttendanceViewModel> lstmvm = new List <AttendanceViewModel>();
            var attendance = _db.tblAttendances.Where(m => m.MemberId == tbm.MembershipId).ToList();

            foreach (var item in attendance)
            {
                lstmvm.Add(new AttendanceViewModel()
                {
                    Status = item.Status, AttendanceDate = item.AttendanceDate
                });
            }
            return(View(lstmvm));
        }
コード例 #10
0
        public ActionResult ViewPayment()
        {
            int           userid = Convert.ToInt32(Session["userid"].ToString());
            tblMembership tbm    = _db.tblMemberships.Where(m => m.UserId == userid).FirstOrDefault();



            List <PaymentViewModel> lstmvm = new List <PaymentViewModel>();
            var payments = _db.tblPayments.Where(m => m.MemberId == tbm.MembershipId).ToList();

            foreach (var item in payments)
            {
                lstmvm.Add(new PaymentViewModel()
                {
                    PaidAmount = item.PaidAmount, PaymentDate = item.PaymentDate
                });
            }
            return(View(lstmvm));
        }
コード例 #11
0
        public ActionResult Edit(MemberViewModel memvm)
        {
            if (ModelState.IsValid)
            {
                tblMembership tb  = _db.tblMemberships.Where(m => m.MembershipId == memvm.MemberId).FirstOrDefault();
                tblUser       tbu = _db.tblUsers.Where(u => u.UserId == memvm.UserId).FirstOrDefault();

                tbu.Fullname = memvm.Fullname;
                tbu.Email    = memvm.Email;
                HttpPostedFileBase fup = Request.Files["Photo"];
                if (fup != null && fup.FileName != "")
                {
                    tbu.Photo = fup.FileName;
                    fup.SaveAs(Server.MapPath("~/MemberPhoto/" + fup.FileName));
                }
                else
                {
                    tbu.Photo = memvm.Photo;
                }

                tbu.Phone           = memvm.Phone;
                tbu.Gender          = memvm.Gender;
                tb.MembershipTypeId = memvm.MemberId;
                tb.Fees             = memvm.Fees;
                tb.RegDate          = memvm.RegDate;
                tb.ShiftId          = memvm.ShiftId;

                string regdate = DateTime.Now.ToString("MM/dd/yyyy");
                tb.RegDate = Convert.ToDateTime(regdate);
                _db.SaveChanges();



                ViewBag.Message = "Member Updated";
            }
            ViewBag.Role = _db.Roles.ToList();

            ViewBag.Shift = _db.tblShifts.ToList();

            ViewBag.MembershipType = _db.tblMembershipTypes.ToList();
            return(View(memvm));
        }
コード例 #12
0
        public ActionResult GetMemberTotalPaymentAmount(int memberid)
        {
            tblMembership     tbmem            = _db.tblMemberships.Where(m => m.MembershipId == memberid).FirstOrDefault();
            int?              membershiptypeid = tbmem.MembershipTypeId;
            tblMembershipType tbmtype          = _db.tblMembershipTypes.Where(mem => mem.MembershipTypeId == membershiptypeid).FirstOrDefault();
            //int? month = tbmtype.AllowedMonth;
            //int? totaldays = month * 30;

            //SqlConnection con = new SqlConnection("Data Source=.; Integrated Security=true; Database=GymDB");
            //SqlCommand cmd = new SqlCommand("select Sum(PaidAmount) as TotalAmount from tblPayment where PaymentDate>=(Getdate()-"+totaldays+") group by MemberId", con);

            //SqlDataAdapter da = new SqlDataAdapter(cmd);
            //DataTable dt = new DataTable();
            //da.Fill(dt);
            //var totalamount = dt.Rows[0][0].ToString();
            //var states = _db.tblPayments.Where(m => m.MemberId == memberid).FirstOrDefault();
            var price = tbmtype.Price;

            return(Json(price, JsonRequestBehavior.AllowGet));
        }
コード例 #13
0
        public ActionResult Add(AttendanceViewModel atv)
        {
            if (ModelState.IsValid)
            {
                tblAttendance tbat = db.tblAttendances.Where(a => a.MemberId == atv.MemberId && a.AttendanceDate == DateTime.Today).FirstOrDefault();
                if (tbat != null)
                {
                    ViewBag.Message = "Attendance Already Done";
                }
                else
                {
                    tblAttendance tb = new tblAttendance();

                    tb.MemberId       = atv.MemberId;
                    tb.Status         = atv.Status;
                    tb.AttendanceDate = atv.AttendanceDate;
                    db.tblAttendances.Add(tb);
                    db.SaveChanges();

                    ViewBag.Message = "Attendance Done Successfully";
                }
            }

            List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

            var users = db.tblUsers.Where(u => u.Usertype == "User").ToList();

            foreach (var item in users)
            {
                tblMembership tbm = db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                if (tbm != null)
                {
                    lstmemvm.Add(new MemberViewModel()
                    {
                        MemberId = tbm.MembershipId, Fullname = item.Fullname
                    });
                }
            }
            ViewBag.Fullname = lstmemvm;
            return(View());
        }
コード例 #14
0
        public ActionResult ViewMeasurement()
        {
            int           userid = Convert.ToInt32(Session["userid"].ToString());
            tblMembership tbm    = _db.tblMemberships.Where(m => m.UserId == userid).FirstOrDefault();



            List <MeasurementViewModel> lstmvm = new List <MeasurementViewModel>();
            var measures = _db.tblMeasurements.Where(m => m.MemberId == tbm.MembershipId).ToList();

            foreach (var item in measures)
            {
                tblMembership tb  = _db.tblMemberships.Where(m => m.MembershipId == item.MemberId).FirstOrDefault();
                tblUser       tbu = _db.tblUsers.Where(k => k.UserId == tb.UserId).FirstOrDefault();
                lstmvm.Add(new MeasurementViewModel()
                {
                    MeasurementId = item.MeasurementId, Fullname = tbu.Fullname, MemberId = item.MemberId, Weight = item.Weight, Chest = item.Chest, Weist = item.Weist, Hip = item.Hip, Thigh = item.Thigh, Bicep = item.Bicep, Forearm = item.Forearm, MeasurementDate = item.MeasurementDate
                });
            }
            return(View(lstmvm));
        }
コード例 #15
0
        public ActionResult Edit(tblMeasurement model)
        {
            if (ModelState.IsValid)
            {
                tblMeasurement tb = db.tblMeasurements.Where(m => m.MeasurementId == model.MeasurementId).FirstOrDefault();
                tb.MemberId        = model.MemberId;
                tb.Weight          = model.Weight;
                tb.Chest           = model.Chest;
                tb.Weist           = model.Weist;
                tb.Hip             = model.Hip;
                tb.Thigh           = model.Thigh;
                tb.Bicep           = model.Bicep;
                tb.Forearm         = model.Forearm;
                tb.MeasurementDate = model.MeasurementDate;

                db.SaveChanges();


                List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

                var users = db.tblUsers.ToList();
                foreach (var item in users)
                {
                    tblMembership tbm = db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                    if (tbm != null)
                    {
                        lstmemvm.Add(new MemberViewModel()
                        {
                            MemberId = tbm.MembershipId, Fullname = item.Fullname
                        });
                    }
                }
                ViewBag.Fullname = lstmemvm;

                ViewBag.Message = "Measurement Updated";
            }
            return(View());;
        }
コード例 #16
0
        public ActionResult Add()
        {
            List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

            var users = db.tblUsers.ToList();

            foreach (var item in users)
            {
                tblMembership tbm = db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                if (tbm != null)
                {
                    lstmemvm.Add(new MemberViewModel()
                    {
                        MemberId = tbm.MembershipId, Fullname = item.Fullname
                    });
                }
            }
            MeasurementViewModel mv = new MeasurementViewModel();

            mv.MeasurementDate = DateTime.Today;
            ViewBag.Fullname   = lstmemvm;
            return(View(mv));
        }
コード例 #17
0
        public ActionResult Payment()
        {
            List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

            var users = _db.tblUsers.Where(u => u.Usertype == "User").ToList();

            foreach (var item in users)
            {
                tblMembership tbm = _db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                if (tbm != null)
                {
                    lstmemvm.Add(new MemberViewModel()
                    {
                        MemberId = tbm.MembershipId, Fullname = item.Fullname
                    });
                }
            }
            ViewBag.Fullname = lstmemvm;
            PaymentViewModel pm = new PaymentViewModel();

            pm.PaymentDate = DateTime.Today;
            return(View(pm));
        }
コード例 #18
0
        public ActionResult Edit(int id)
        {
            MeasurementViewModel tb    = new MeasurementViewModel();
            tblMeasurement       model = db.tblMeasurements.Where(m => m.MeasurementId == id).FirstOrDefault();

            tb.MeasurementId   = model.MeasurementId;
            tb.MemberId        = model.MemberId;
            tb.Weight          = model.Weight;
            tb.Chest           = model.Chest;
            tb.Weist           = model.Weist;
            tb.Hip             = model.Hip;
            tb.Thigh           = model.Thigh;
            tb.Bicep           = model.Bicep;
            tb.Forearm         = model.Forearm;
            tb.MeasurementDate = model.MeasurementDate;


            List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

            var users = db.tblUsers.Where(u => u.Usertype == "User").ToList();

            foreach (var item in users)
            {
                tblMembership tbm = db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                if (tbm != null)
                {
                    lstmemvm.Add(new MemberViewModel()
                    {
                        MemberId = tbm.MembershipId, Fullname = item.Fullname
                    });
                }
            }
            ViewBag.Fullname = lstmemvm;


            return(View(tb));
        }
コード例 #19
0
        public ActionResult Add(int MemberId, string SunDesc, string MonDesc, string TueDesc, string WedDesc, string ThuDesc, string FriDesc)
        {
            if (ModelState.IsValid)
            {
                int?memberid = MemberId;

                tblWorkout tb = new tblWorkout();
                tb.MemberId    = memberid;
                tb.WorkoutDays = "Sunday";
                tb.Description = SunDesc;
                _db.tblWorkouts.Add(tb);
                _db.SaveChanges();

                tb.WorkoutDays = "Monday";
                tb.Description = MonDesc;
                _db.tblWorkouts.Add(tb);
                _db.SaveChanges();


                tb.WorkoutDays = "Tuesday";
                tb.Description = TueDesc;
                _db.tblWorkouts.Add(tb);
                _db.SaveChanges();

                tb.WorkoutDays = "Wednesday";
                tb.Description = WedDesc;
                _db.tblWorkouts.Add(tb);
                _db.SaveChanges();

                tb.WorkoutDays = "Thursday";
                tb.Description = ThuDesc;
                _db.tblWorkouts.Add(tb);
                _db.SaveChanges();

                tb.WorkoutDays = "Friday";
                tb.Description = FriDesc;
                _db.tblWorkouts.Add(tb);
                _db.SaveChanges();
            }



            List <MemberViewModel> lstmemvm = new List <MemberViewModel>();

            var users = _db.tblUsers.ToList();

            foreach (var item in users)
            {
                tblMembership tbm = _db.tblMemberships.Where(m => m.UserId == item.UserId).FirstOrDefault();
                if (tbm != null)
                {
                    lstmemvm.Add(new MemberViewModel()
                    {
                        MemberId = tbm.MembershipId, Fullname = item.Fullname
                    });
                }
            }



            ViewBag.Fullname = lstmemvm;
            ViewBag.Message  = "Work out Added Successfully";
            return(View());
        }
コード例 #20
0
        public ActionResult Create(MemberViewModel mem)
        {
            tblUser checkuser = _db.tblUsers.Where(u => u.Username == mem.Username).FirstOrDefault();

            if (checkuser != null)
            {
                ViewBag.Message = "Username Already Taken";
            }
            else
            {
                tblUser checkEmail = _db.tblUsers.Where(u => u.Email == mem.Email).FirstOrDefault();
                if (checkEmail != null)
                {
                    ViewBag.Message = "Email Already Taken";
                }
                else
                {
                    tblUser tb = new tblUser();
                    tb.Fullname = mem.Fullname;
                    tb.Email    = mem.Email;
                    tb.Phone    = mem.Phone;

                    HttpPostedFileBase fup = Request.Files["Photo"];
                    if (fup != null)
                    {
                        tb.Photo = fup.FileName;
                        fup.SaveAs(Server.MapPath("~/MemberPhoto/" + fup.FileName));
                    }
                    tb.Gender   = mem.Gender;
                    tb.Username = mem.Username;
                    tb.Password = mem.Password;

                    _db.tblUsers.Add(tb);
                    _db.SaveChanges();

                    tblMembership tbm = new tblMembership();
                    tbm.UserId           = tb.UserId;
                    tbm.MembershipTypeId = mem.MembershipTypeId;
                    tbm.RegDate          = mem.RegDate;
                    tbm.Fees             = mem.Price;
                    tbm.ShiftId          = mem.ShiftId;



                    _db.tblMemberships.Add(tbm);
                    _db.SaveChanges();

                    UserRole ur = new UserRole();
                    ur.RoleId = mem.RoleId;
                    ur.UserId = tb.UserId;
                    _db.UserRoles.Add(ur);
                    _db.SaveChanges();

                    tblPayment pay = new tblPayment();
                    pay.MemberId        = tbm.MembershipId;
                    pay.PaidAmount      = mem.Price;
                    pay.RemainingAmount = 0.0M;
                    pay.PaymentDate     = DateTime.Today;
                    _db.tblPayments.Add(pay);
                    _db.SaveChanges();
                    ViewBag.Message = "Member Added";
                }
            }



            string regdate = DateTime.Now.ToString("MM/dd/yyyy");

            ViewBag.Role = _db.Roles.ToList();

            ViewBag.Shift = _db.tblShifts.ToList();

            ViewBag.MembershipType = _db.tblMembershipTypes.ToList();

            return(View(mem));
        }