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"));
 }
Exemple #2
0
        public string InsertStaff(InsertStaff obj)
        {
            string returnResult = (dynamic)null;

            try
            {
                if (obj != null)
                {
                    //[Note: insert 'states' table]
                    if (obj.Staffs != null)
                    {
                        var Staffs = new InsertStaff_Staffs()
                        {
                            GenderId      = obj.Staffs.GenderId,
                            IP300X200     = obj.Staffs.IP300X200,
                            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
                        };

                        _StaffsRepo.Insert(Staffs);
                        if (obj.Staffs.fleImage != null)
                        {
                            string imagePathIP300X200 = "ClientDictionary/Staffs/IP300X200/";
                            string extension          = Path.GetExtension(obj.Staffs.fleImage.FileName);
                            var    lastAddingRecord   = _StaffsRepo.GetAll().Last();
                            if (_commonServ.CommImage_ImageFormat(lastAddingRecord.Id.ToString(), obj.Staffs.fleImage, obj.WebRootPath, imagePathIP300X200, 200, 300, extension).Equals(true))
                            {
                                //[NOTE:Update image file]
                                var imgStaff = _StaffsRepo.Get(lastAddingRecord.Id);
                                imgStaff.IP300X200 = imagePathIP300X200 + lastAddingRecord.Id + extension;
                                _StaffsRepo.Update(imgStaff);
                            }
                        }
                        returnResult = "Saved";
                    }
                }
            }
            catch (Exception ex)
            {
                returnResult = "ERROR102:ClassesServ/InsertClassessList - " + ex.Message;
            }

            return(returnResult);
        }
Exemple #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);
        }