public async Task <IActionResult> InsertStaff(IndexStaffsListVM obj)
 {
     try
     {
         if (obj.Staffs != null)
         {
             var Staffs = new InsertStaff_Staffs()
             {
                 GenderId      = obj.Staffs.GenderId,
                 IP300X200     = obj.Staffs.IP300X200,
                 fleImage      = obj.Staffs.fleImage,
                 DesignationId = obj.Staffs.DesignationId,
                 FirstName     = obj.Staffs.FirstName,
                 LastName      = obj.Staffs.LastName,
                 Cell          = obj.Staffs.Cell,
                 Email         = obj.Staffs.Email,
                 Address       = obj.Staffs.Address
             };
             var model = new InsertStaff()
             {
                 Staffs      = Staffs,
                 WebRootPath = _he.WebRootPath,
             };
             await Task.Run(() => _StaffsServ.InsertStaff(model));
         }
     }
     catch (Exception)
     {
         return(BadRequest());
     }
     return(RedirectToAction("StaffList"));
 }
Beispiel #2
0
        //public async Task<IActionResult>InsertStaff(IndexStaffsListVM obj)
        public JsonResult InsertStaff(IndexStaffsListVM obj)
        {
            var    result  = (dynamic)null;        //for jsonResult
            string message = (dynamic)null;

            try
            {
                if (obj.Staffs != null)
                {
                    var Staffs = new InsertStaff_Staffs()
                    {
                        GenderId      = obj.Staffs.GenderId,
                        IP300X200     = obj.Staffs.IP300X200,
                        fleImage      = obj.Staffs.fleImage,
                        DesignationId = obj.Staffs.DesignationId,
                        FirstName     = obj.Staffs.FirstName,
                        LastName      = obj.Staffs.LastName,
                        Cell          = obj.Staffs.Cell,
                        Email         = obj.Staffs.Email,
                        Education     = obj.Staffs.Education,
                        Address       = obj.Staffs.Address
                    };

                    var model = new InsertStaff()
                    {
                        Staffs      = Staffs,
                        WebRootPath = _he.WebRootPath,
                    };

                    // await Task.Run(() => _StaffsServ.InsertStaff(model));
                    message = _StaffsServ.InsertStaff(model);
                    result  = Json(new { success = true, Message = message });
                }
            }
            catch (Exception ex)
            {
                // return BadRequest();
                result = Json(new { success = false, Message = "ERROR101:Students/InsertStudent - " + ex.Message });
            }
            //return RedirectToAction("StaffsListByAdmin");
            //  return RedirectToRoute("StaffsListByAdmin");
            // return View ("StaffsListByAdmin");
            return(result);
        }