コード例 #1
0
        public ActionResult AddChild(AddChildModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }
            var memberService = Services.MemberService;

            try
            {
                var    parentProfile = System.Web.Security.Membership.GetUser();
                var    parentEmail   = parentProfile.Email;
                string trimpedName   = model.Name.Replace(" ", "");
                var    kidsEmaill    = trimpedName + "@email.com";
                var    member        = memberService.CreateMemberWithIdentity(model.Name, kidsEmaill, model.Name, "childMember");
                member.SetValue("parentEmail", parentEmail);
                member.SetValue("childPaymentStatus", "Unpaid");
                member.SetValue("childLessonsCompleted", "?");
                memberService.Save(member);
                var parent = memberService.GetByUsername(parentProfile.UserName);
                parent.SetValue("haveChildren", "HaveChild");
                memberService.Save(parent);
                return(Redirect("/your-kids"));
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Error occured while adding a child");
                return(CurrentUmbracoPage());
            }
        }
コード例 #2
0
 /// <summary>
 /// Add Child
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 private string AddChild(AddChildModel model)
 {
     _dataModelManager.GetDefaultDataModel(Enums.SQLOperation.INSERT, DBEntityNames.Tables.Child.ToString());
     _dataModelManager.AddParameter(DBEntityNames.Child.Responsible.ToString(), Enums.ParameterType._int, Common.GetResponsibleId());
     // Returns child id
     return(_manager.InsertData(_dataModelManager.DataModel).Rows[0][DBEntityNames.Child.Id.ToString()].ToString());
 }
コード例 #3
0
ファイル: NavBarController.cs プロジェクト: 080779/SYS
        public async Task <ActionResult> AddChild(AddChildModel model)
        {
            await navbarService.AddChild(model.MenuName, model.Url, model.Sort, model.ParentId);

            return(Json(new AjaxResult {
                Status = "1"
            }));
        }
コード例 #4
0
        // POST api/values
        public IHttpActionResult AddChildApi(AddChildModel input)
        {
            // add child
            var childId = AddChild(input);

            AddChildName(input.ChildName, input.CaseNumber, childId);
            return(Ok(Common.ToJson(childId)));
        }