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> StaffsList(int pg = 1)
        {
            try
            {
                ViewBag.ddlGenders = _GendersServ.Dropdown_Genders();
                var StaffsList = Task.Run(() => _StaffsServ.getStaffsList(new Service.ServiceModels.StaffsServ.getStaffsList()
                {
                    WebRootPath = _he.WebRootPath
                }));
                var result = await StaffsList;
                ViewBag.ddlDesignations = _DesignationsServ.dropdown_Designations();
                var list = new List <IndexStaffsListVM_Staffs>();
                foreach (var item in result._Staffs.ToList())
                {
                    var temp = new IndexStaffsListVM_Staffs()
                    {
                        Id            = item.Id,
                        GenderId      = item.GenderId,
                        GenderName    = item.GenderName,
                        IP300X200     = item.IP300X200,
                        DesignationId = item.DesignationId,
                        FirstName     = item.FirstName,
                        LastName      = item.LastName,
                        Name          = item.Name,
                        Designation   = item.Designation,
                        Cell          = item.Cell,
                        Email         = item.Email,
                        Education     = item.Education,
                        Address       = item.Address
                    };
                    list.Add(temp);
                }
                ;

                #region "Paging"
                const int pageSize = 5;
                if (pg < 1)
                {
                    pg = 1;
                }
                int recsCount = list.Count();
                var pager     = new Pager(recsCount, pg, pageSize);
                int recSkip   = (pg - 1) * pageSize;
                var data      = list.Skip(recSkip).Take(pager.PageSize).ToList();
                this.ViewBag.Pager = pager;
                var model = new IndexStaffsListVM()
                {
                    _Staffs = data
                };
                #endregion "Paging"

                return(View("StaffsList", model));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Beispiel #3
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);
        }