public ResultViewModel <AdminEditViewModel> Post([FromBody] AdminEditViewModel Admin)
        {
            ResultViewModel <AdminEditViewModel> result
                = new ResultViewModel <AdminEditViewModel>();

            try
            {
                if (!ModelState.IsValid)
                {
                    result.Message = "In Valid Model State";
                }
                else
                {
                    AdminEditViewModel selectedAdmin
                        = adminService.Add(Admin);

                    result.Successed = true;
                    result.Data      = selectedAdmin;
                }
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "Semething Went Wrong";
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        // POST: api/Admin
        public async Task <IHttpActionResult> Post([FromBody] Admin value)
        {
            try
            {
                Admin model = await bll.Add(value);

                if (model.Id > 0)
                {
                    return(this.JsonMy(new AjaxResult <Admin> {
                        Code = 1, Msg = "添加成功"
                    }));
                }
                else
                {
                    return(this.JsonMy(new AjaxResult <Admin> {
                        Code = 0, Msg = "请求失败"
                    }));
                }
            }
            catch (Exception e)
            {
                var msg = "请求失败";
#if DEBUG
                msg = e.Message;
#endif
                return(this.JsonMy(new AjaxResult <Admin> {
                    Code = 0, Msg = msg
                }));
            }
        }
        public ResultViewModel <AdminEditViewModel> Post(AdminEditViewModel Admin)
        {
            ResultViewModel <AdminEditViewModel> result
                = new ResultViewModel <AdminEditViewModel>();

            try
            {
                if (!ModelState.IsValid)
                {
                    result.Message = "In Valid Model State";
                }
                else
                {
                    if (adminService.CheckEmail(Admin.Email))
                    {
                        AdminEditViewModel selectedAdmin
                            = adminService.Add(Admin);

                        result.Successed = true;
                        result.Data      = selectedAdmin;
                    }
                    else
                    {
                        result.Successed = false;
                        result.Message   = "Eamil Already Tpken";
                    }
                }
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "Semething Went Wrong";
            }
            return(result);
        }
        public ResultViewModel <AdminEditViewModel> Post(AdminEditViewModel model)
        {
            ResultViewModel <AdminEditViewModel> result
                = new ResultViewModel <AdminEditViewModel>();

            try
            {
                if (!ModelState.IsValid)
                {
                    result.Message = "In Valid Model State";
                }
                else
                {
                    AdminEditViewModel selectedUser
                        = AdminService.Add(model);
                    result.Successed = true;
                    result.Data      = selectedUser;
                }
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "حدث خطأ ما";
            }
            return(result);
        }
        public ActionResult DoAdminSignUp(Admin admin)
        {
            var service = new AdminService();

            return(Json(service.Add(admin)));
        }
예제 #6
0
 public static int Add(Admin ad)
 {
     return(AdminService.Add(ad));
 }
예제 #7
0
        public AdminEditViewModel AddAdmin(AdminEditViewModel adminEditView)
        {
            var admin = adminService.Add(adminEditView);

            return(admin);
        }