Exemple #1
0
        public IHttpActionResult SaveExaminor([FromBody] SaveMemberViewModel model)
        {
            var committee = _db.CommitteesRepository.FindBy(model.CommitteeId);

            var member = Mapper.Map(model.Member);

            member.CommitteeId = model.CommitteeId;

            if (model.Member.Id == 0)
            {
                committee.Examinors.Add(member);
            }
            else
            {
                var examinor = committee.Examinors.FirstOrDefault(m => m.Id == model.Member.Id);
                committee.Examinors.Remove(examinor);
                committee.Examinors.Add(member);
            }

            _db.Commit();


            member.Job = _db.JobsRepository.FindBy(member.JobId);

            return(Ok(committee.Examinors));
        }
        public IActionResult Register([Bind("Id,SponsorId,Lname,Fname,Mi,Birthdate,Beneficiary,Address,City,Province,ZipCode,ContactNo,Gender,Email,BankAccount,Username,Password,ConfirmPassword,TinNo,product_code,pin_code")] SaveMemberViewModel member)
        {
            if (ModelState.IsValid)
            {
                var result = _context.LoadStoredProc("dbo.SaveMember")
                             .WithSqlParam("id", 0)
                             .WithSqlParam("lname", member.Lname)
                             .WithSqlParam("fname", member.Fname)
                             .WithSqlParam("mi", member.Mi)
                             .WithSqlParam("birthdate", member.Birthdate)
                             .WithSqlParam("beneficiary", member.Beneficiary)
                             .WithSqlParam("address", member.Address)
                             .WithSqlParam("city", member.City)
                             .WithSqlParam("province", member.Province)
                             .WithSqlParam("zip_code", member.ZipCode == null ? string.Empty : member.ZipCode)
                             .WithSqlParam("contact_no", member.ContactNo == null ? string.Empty : member.ContactNo)
                             .WithSqlParam("gender", member.Gender)
                             .WithSqlParam("email", member.Email == null ? string.Empty : member.Email)
                             .WithSqlParam("bank_account", member.BankAccount == null ? string.Empty : member.BankAccount)
                             .WithSqlParam("sponsor_id", member.SponsorId)
                             .WithSqlParam("date_join", DateTime.Now)
                             .WithSqlParam("tin_no", member.TinNo == null ? string.Empty : member.TinNo)

                             .WithSqlParam("username", member.Username)
                             .WithSqlParam("password", member.Password)

                             .WithSqlParam("purchase_type", 1)
                             .WithSqlParam("product_id", 1)
                             .WithSqlParam("product_code", member.product_code)
                             .WithSqlParam("pin_code", member.pin_code)
                             .WithSqlParam("qty", 1)
                             .WithSqlParam("amount", 1800)
                             .WithSqlParam("discount", 0)
                             .WithSqlParam("program_id", 1)
                             .WithSqlParam("comm", 0)

                             .ExecuteStoredProc <SaveMemberViewModel_Result>()
                             .Single();

                var sponsor = _context.Member.Where(m => m.Id == member.SponsorId).FirstOrDefault();
                if (sponsor != null)
                {
                    ViewBag.Sponsor_Id   = sponsor.Id;
                    ViewBag.Sponsor_Name = sponsor.Fname + " " + sponsor.Lname;
                }

                ViewBag.Result    = result.message;
                ViewBag.Member_Id = result.member_id;
                if (result.message == "SUCCESS")
                {
                    return(RedirectToAction("Login", "Account"));
                }
                else
                {
                    return(View(member));
                }
            }
            return(View(member));
        }
Exemple #3
0
        public ActionResult NewMember()
        {
            var _context = new DbCaimanContext();
            var spe      = _context.Specialites.ToList();
            var Tra      = _context.Transports.ToList();

            var pm = new SaveMemberViewModel()
            {
                Specialites = spe,
                Transports  = Tra
            };

            _context.Dispose();
            return(View(pm));
        }
Exemple #4
0
        public ActionResult NewMember(Member member)
        {
            var _context    = new DbCaimanContext();
            var specialites = _context.Specialites.ToList();
            var Tra         = _context.Transports.ToList();
            var vM          = new SaveMemberViewModel
            {
                Specialites = specialites,
                Transports  = Tra
            };

            if (!ModelState.IsValid)
            {
                vM.Member = member;
                return(View(vM));
            }
            var tar = new Transport();

            if (member.SpecialiteId == 0)
            {
                ViewBag.PasSpe = "Veuillez d'abord cree une specialite !";
                vM.Member      = member;
                return(View(vM));
            }
            if (ModelState.IsValid)
            {
                var date = DateTime.Today.Year;
                if (member.MemberNaissance.Year >= date)
                {
                    ViewData["errordate"] = "L'année doit etre inférieure a l'année actuelle";
                    vM.Member             = member;
                    return(View(vM));
                }


                Specialite _Specialite = _context.Specialites.FirstOrDefault(Sp => Sp.SpecialiteId == member.SpecialiteId);
                _Specialite.Members = new List <Member>();
                var memberAdd = new Member();
                memberAdd = member;

                /*memberAdd.MemberCommune = member.MemberCommune;
                 * memberAdd.MemberName = member.MemberName;
                 * memberAdd.MemberPnom = member.MemberPnom;
                 * memberAdd.MemberDescription = member.MemberDescription;
                 * memberAdd.MemberLieuNaissance = member.MemberLieuNaissance;
                 * memberAdd.MemberNaissance = member.MemberNaissance;
                 * memberAdd.MemberPhone = member.MemberPhone;
                 * memberAdd.MemberQuartier = member.MemberQuartier;
                 * memberAdd.MemberMail = member.MemberMail;
                 * memberAdd.MemberTransport = member.MemberTransport;
                 * memberAdd.MemberSex = member.MemberSex;*/
                Transport _Transport = _context.Transports.FirstOrDefault(Tr => Tr.TransportId == member.TransportId);

                _Transport.Members = new List <Member>();


                if (_Specialite != null)
                {
                    _Specialite.Members.Add(memberAdd);
                    _context.Specialites.Update(_Specialite);
                }
                _Transport.Members.Add(memberAdd);

                _context.Transports.Add(_Transport);
                _context.SaveChanges();
                _context.Dispose();

                return(RedirectToAction("ProfilMember", "Departement", new { id = memberAdd.MemberId }));
            }
            return(View());
        }