Пример #1
0
        public async Task <ActionResult> New()
        {
            //Connect to db to get list of members
            MemberEdit memberEditView = new MemberEdit();

            memberEditView.Teams = await db.Teams.ToListAsync();

            return(View(memberEditView));
        }
Пример #2
0
        public async Task <ActionResult> Edit(int id)
        {
            //Need list of members and the current member
            MemberEdit memberEditView = new MemberEdit();

            memberEditView.Teams = await db.Teams.ToListAsync();

            memberEditView.Member = await db.Members.FindAsync(id);

            return(View(memberEditView));
        }
Пример #3
0
        public IHttpActionResult Put([FromBody] MemberEdit member)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateMemberService();

            if (!service.UpdateMember(member))
            {
                return(InternalServerError());
            }

            return(Ok("Member updated!"));
        }
Пример #4
0
        // GET: Member/Edit
        public ActionResult Edit(int id)
        {
            var service = CreateMemberService();
            var detail  = service.GetMemberByID(id);
            var model   = new MemberEdit
            {
                MemberID  = detail.MemberID,
                FirstName = detail.FirstName,
                LastName  = detail.LastName,
                Location  = detail.Location,
                FullName  = $"{detail.FirstName} {detail.LastName}"
            };

            return(View(model));
        }
Пример #5
0
        public bool UpdateMember(MemberEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Members.Single
                                 (e => e.MemberID == model.MemberID && e.OwnerID == _userID);
                {
                    entity.MemberID  = model.MemberID;
                    entity.FirstName = model.FirstName;
                    entity.LastName  = model.LastName;
                    entity.Location  = model.Location;

                    return(ctx.SaveChanges() == 1);
                }
            }
        }
Пример #6
0
        public bool UpdateMember(MemberEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .Members
                             .Single(e => e.MemberID == model.MemberID);

                //entity.MemberID = model.MemberID;
                entity.Name             = model.Name;
                entity.Email            = model.Email;
                entity.Address          = model.Address;
                entity.PhoneNumber      = model.PhoneNumber;
                entity.CreditCardNumber = model.CreditCardNumber;
                entity.ExpirationDate   = model.ExpirationDate;
                entity.SecurityCode     = model.SecurityCode;
                entity.LocationID       = model.LocationID;

                return(ctx.SaveChanges() == 1);
            }
        }
Пример #7
0
        public ActionResult Edit(int id, MemberEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.MemberID != id)
            {
                ModelState.AddModelError("", "Member ID's Do Not Match");
                return(View(model));
            }

            var service = CreateMemberService();

            if (service.UpdateMember(model))
            {
                TempData["SaveResult"] = "Your Profile Has Been Updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Nothing Was Changed, Please Enter Your Changes.");
            return(View(model));
        }
Пример #8
0
        private void memberEditBtn_Click(object sender, EventArgs e)
        {
            var memberForm = new MemberEdit();

            Nav(memberForm, contentPanel);
        }