Exemplo n.º 1
0
        public async Task <IActionResult> UpdateMember([FromBody] AddMemberModel member)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var MemberUpdate = await appDbContext.Members.SingleOrDefaultAsync(s => s.MemberId == member.MemberId);

            if (MemberUpdate != null)
            {
                MemberUpdate.FirstName   = member.FirstName;
                MemberUpdate.LastName    = member.LastName;
                MemberUpdate.JoiningDate = member.JoiningDate;

                var ContactUpdate = await appDbContext.ContactDetails.SingleOrDefaultAsync(s => s.MemberId == member.MemberId);

                if (ContactUpdate != null)
                {
                    ContactUpdate.EmailAddress = member.EmailAddress;
                    ContactUpdate.MobileNo     = member.MobileNo;
                }

                var AddressUpdate = await appDbContext.Addresses.SingleOrDefaultAsync(s => s.MemberId == member.MemberId);

                if (AddressUpdate != null)
                {
                    AddressUpdate.AddressLine = member.AddressLine;
                    AddressUpdate.CityName    = member.CityName;
                    AddressUpdate.StateName   = member.StateName;
                }
            }
            await appDbContext.SaveChangesAsync();

            return(new OkObjectResult("{}"));
        }
Exemplo n.º 2
0
 public AddMember(AddMemberModel model)
 {
     InitializeComponent();
     this.model          = model;
     this.DataContext    = model;
     model.requestClose += HandleRequestClose;
 }
Exemplo n.º 3
0
        public ActionResult Add(AddMemberModel member)
        {
            // ok, so I created a class called AddMemberModel. It's sort of like a viewmodel, but
            // used to get the data from the page. The app will automatically bind all the html
            // input fields to properties of this class, provided they have the same name.
            // (There might be a way to customize that but it's irrelevant.)

            // Also, yes the AddMemberModel has all the same properties as the Member class in the
            // database, but this just shows good practice (also that won't always be true, the db
            // could have tons of extra stuff we don't want.)

            this.db.Members.Add(new Member()
            {
                SubRealmId = member.SubRealmId,
                FirstName  = member.FirstName,
                LastName   = member.LastName,
                BattleName = member.BattleName
            });

            // this SaveChanges call is needed to update the db after doing any adds or updates.
            // You don't have to call it after every change, just once at the end of your code is fine.
            this.db.SaveChanges();

            // instead of returning a view, we will redirect back to the index.
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        public IActionResult AddMember(AddMemberModel inputModel)
        {
            if (ModelState.IsValid)
            {
                this.task1Service.AddMember(inputModel);
            }

            return(LocalRedirect("/Task1/Index"));
        }
Exemplo n.º 5
0
        public HttpResponseMessage Add([FromBody] AddMemberModel model)
        {
            MemberDTO member = model.member;

            member.ProfileImage = saveImage(model.image, model.name);


            return(Request.CreateResponse(HttpStatusCode.OK, this.member.Insert(member)));
        }
Exemplo n.º 6
0
        public void AddMember(AddMemberModel model)
        {
            Person newMember = Task1Repo.GetPerson(model.MemberId);
            Family family    = Task1Repo.GetFamily(model.FamilyId);

            if (newMember != null && family != null)
            {
                family.AddMember(newMember);
            }
        }
        public IHttpActionResult AddMember([FromBody] AddMemberModel add)
        {
            var addMember = new MessageHeaderAddMemberDTO
            {
                MessageHeaderId = add.MessageHeaderId,
                UserId          = add.UserId
            };

            _messageHeaderService.AddMember(addMember);
            return(Ok());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> AddMember([FromBody] AddMemberModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            await appDbContext.Members.AddAsync(new Member { MemberId = model.MemberId, JoiningDate = model.JoiningDate, FirstName = model.FirstName, LastName = model.LastName });


            await appDbContext.ContactDetails.AddAsync(new ContactDetail { MemberId = model.MemberId, EmailAddress = model.EmailAddress, MobileNo = model.MobileNo });

            await appDbContext.Addresses.AddAsync(new Address { MemberId = model.MemberId, AddressLine = model.AddressLine, CityName = model.CityName, StateName = model.StateName });

            appDbContext.SaveChanges();


            return(new OkObjectResult("{}"));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Add(AddMemberModel model)
        {
            if (ModelState.IsValid)
            {
                var cliemUserID = User.Claims.FirstOrDefault(a => a.Type.Equals("UserID"));
                var userID      = int.Parse(cliemUserID.Value.ToString());
                var addedMember = new Member()
                {
                    CreatedDate          = DateTime.Now,
                    isTRCitezen          = model.isTRCitizen == "on",
                    isTRIDCitizenVerfied = true,
                    LastUpdatedDate      = DateTime.Now,
                    TRIDNo                = model.TRIDNo,
                    Name                  = model.Name.ToUpper(),
                    Surname               = model.Surname.ToUpper(),
                    UserID                = userID,
                    BirthDate             = new DateTime(model.BirthYear, 1, 1),
                    TotalRentConut        = model.MaxRentLimit,
                    EMail                 = model.EMail.ToLower(),
                    PhoneNumber           = model.PhoneNumber,
                    isEMailVerified       = true,
                    isPhoneNumberVerified = model.isPhonumberVerified == "on",
                    Address               = model.Address.ToUpper(),
                    isAddressVerified     = model.isAddressVerified == "on",
                    Status                = model.isActive == "on"?MemberStatusType.Acitive:MemberStatusType.Suspanded,
                    RemainedRentConut     = model.MaxRentLimit,
                    AwaableToRent         = model.isAwaableToRent == "on"
                };

                var operationResult = await memberService.AddAsync(addedMember);

                if (operationResult.isSuccess)
                {
                    return(RedirectToAction("Index"));
                }
                foreach (var item in operationResult.Errors)
                {
                    ModelState.AddModelError("", item);
                }
            }
            return(View(model));
        }
Exemplo n.º 10
0
        public HttpResponseMessage Post(AddMemberModel model)
        {
            MemberBL  memberBL = new MemberBL();
            MemberDTO member   = model.member;

            member.Image = saveImage(model.image, model.name);
            ResponseFormat <bool> response = new ResponseFormat <bool>();

            response.Data = memberBL.Create(member);
            if (response.Data)
            {
                response.Message = "Member Created";
                response.Success = true;
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            else
            {
                response.Message = "There Was Some Error";
                response.Success = false;
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
        }