示例#1
0
        public async Task <IActionResult> Create([Bind("ID,DsheSL,TraineeType,Course_Name,BatchNo,OpeningDate,ClosingDate,LastNaemCourseAttendeded,Name,FatherName,MotherName,Gender,DateOfBirth,BloodGroup,MaritalStatus,Age,CellNo,Email,NID,PermanentAddress,Designation,IndexNo,NameOfCadre,BCSBatchNo,WorkplaceAddress,EiinNo,AcademicQualification,Subject,EmmergencyContactName,EmmergencyContactCellNo,ProfileImagePath,SignatureImgPath,RegDate,Guid,HomeDistrict")] Trainee trainee, IFormFile ProfileImg, IFormFile SignatureImg)
        {
            if (ModelState.IsValid)
            {
                var name = trainee.Name;
                name = name.Replace(" ", "_");
                var batchNo = trainee.BatchNo;
                if (ProfileImg != null && ProfileImg.Length > 0 && SignatureImg != null && SignatureImg.Length > 0)
                {
                    string dateImg  = _imageProcess.CreateImgName(ProfileImg, name, batchNo);
                    string dateSign = _imageProcess.CreateSigName(SignatureImg, name, batchNo);

                    _imageProcess.SetImgPath(_env, dateImg);
                    await _imageProcess.SaveImg(ProfileImg);

                    _imageProcess.PhotoResize();

                    _imageProcess.SetImgPath(_env, dateSign);
                    await _imageProcess.SaveImg(SignatureImg);

                    _imageProcess.PhotoResize();

                    trainee.ProfileImagePath = ImageProcess.imgUrlDb + dateImg;
                    trainee.SignatureImgPath = ImageProcess.imgUrlDb + dateSign;

                    trainee.RegDate = DateTime.Now;
                    trainee.Guid    = System.Guid.NewGuid().ToString();
                    _context.Add(trainee);
                    await _context.SaveChangesAsync();

                    int id = trainee.ID;


                    // return RedirectToAction(nameof(Index));
                    // return RedirectToActiosn(nameof(Success));
                    return(RedirectToAction("Success", new { id = id }));
                }

                /*  _context.Add(trainee);
                 * await _context.SaveChangesAsync();
                 * return RedirectToAction(nameof(Index)); */
                // return Content($"{ProfileImg.Length},and {SignatureImg.ContentType}");
            }
            return(View(trainee));
            //return Content("AB ");
        }
示例#2
0
        public async Task <IActionResult> GenerateID(int id, [Bind("ID,DsheSL,TraineeType,Course_Name,BatchNo,OpeningDate,ClosingDate,LastNaemCourseAttendeded,Venue,Name,FatherName,MotherName,Gender,DateOfBirth,BloodGroup,MaritalStatus,Age,CellNo,Email,NID,PermanentAddress,Designation,IndexNo,NameOfCadre,BCSBatchNo,WorkplaceAddress,EiinNo,AcademicQualification,Subject,EmmergencyContactName,EmmergencyContactCellNo,ProfileImagePath,SignatureImgPath,RegDate,Guid,TraineeSerial,HomeDistrict")] Trainee trainee, IFormFile editPhoto, IFormFile editSign, string ProfileImagePath, string SignatureImgPath)
        {
            if (id != trainee.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                int bn;
                var name = trainee.Name;
                name = name.Replace(" ", "_");
                var batchNo = trainee.BatchNo;

                if (editPhoto != null)

                {
                    if (editPhoto.Length > 0)
                    {
                        string dateImg = _imageProcess.CreateImgName(editPhoto, name, batchNo);

                        _imageProcess.SetImgPath(_env, dateImg);
                        await _imageProcess.SaveImg(editPhoto);

                        _imageProcess.PhotoResize();
                        trainee.ProfileImagePath = ImageProcess.imgUrlDb + dateImg;
                    }
                }
                if (editSign != null)
                {
                    if (editSign.Length > 0)
                    {
                        string dateSign = _imageProcess.CreateSigName(editSign, name, batchNo);
                        _imageProcess.SetImgPath(_env, dateSign);
                        await _imageProcess.SaveImg(editSign);

                        _imageProcess.PhotoResize();
                        trainee.SignatureImgPath = ImageProcess.imgUrlDb + dateSign;
                    }
                }
                try
                {
                    //trainee.RegDate =
                    _context.Update(trainee);
                    await _context.SaveChangesAsync();

                    bn               = trainee.BatchNo;
                    ViewBag.Batch    = trainee.BatchNo;
                    ViewBag.Duration = trainee.OpeningDate.ToString("yyyyy/MM/dd") + " - " + trainee.ClosingDate.ToString("yyyy/MM/dd");
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TraineeExists(trainee.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction("List","Trainee");
                // return Content("");
                return(RedirectToAction("ShowIDPage", new { bn = bn }));
            }
            return(View(trainee));
            //return Content("");
        }