public ActionResult PIOCMaster(string id)
 {
     ViewBag.CourseList   = new SelectList(_course.GetAll(), "pkid", "CourseName");
     ViewBag.DivisionList = new SelectList(_division.GetAll(), "pkid", "DivisioName");
     ViewBag.ForceList    = new SelectList(_force.GetAll(), "pkid", "ForceName");
     ViewBag.StudentList  = new SelectList(_student.GetAll(), "pkid", "FullName");
     ViewBag.SessionList  = new SelectList(_sessionmaster.GetAll(), "pkid", "OtherData");
     if (!String.IsNullOrWhiteSpace(id))
     {
         int _id = Convert.ToInt32(id);
         tbl_PIOC_Arrival_DataMasterss abc   = new tbl_PIOC_Arrival_DataMasterss();
         tbl_PIOC_Arrival_DataMaster   model = _PIOCMaster.Get(_id);
         abc.pkid                 = model.pkid;
         abc.Course_fkid          = model.Course_fkid;
         abc.Division_fkid        = model.Division_fkid;
         abc.Force_fkid           = model.Force_fkid;
         abc.Session_fkid         = model.Session_fkid;
         abc.Student_fkid         = model.Student_fkid;
         abc.ChestNo              = model.ChestNo;
         abc.ArmyNo               = model.ArmyNo;
         abc.Rank                 = model.Rank;
         abc.ParentUnit           = model.ParentUnit;
         abc.Records              = model.Records;
         abc.NCCUnit              = model.NCCUnit;
         abc.DateOfArrival        = model.DateOfArrival;
         abc.DTE                  = model.DTE;
         abc.DateofDEP            = model.DateofDEP;
         abc.MoveOrder            = model.MoveOrder;
         abc.IdentityCard         = model.IdentityCard;
         abc.MobileNo             = model.MobileNo;
         abc.IMEIno               = model.IMEIno;
         abc.AddedDate            = model.AddedDate;
         abc.MedicalCertificate   = model.MedicalCertificate;
         abc.SignofIndividual     = model.SignofIndividual;
         abc.CharacterCertificate = model.CharacterCertificate;
         return(View(abc));
     }
     return(View());
 }
 public ActionResult PIOCMaster(tbl_PIOC_Arrival_DataMasterss model, HttpPostedFileBase MED, HttpPostedFileBase CHR, HttpPostedFileBase SIG)
 {
     try
     {
         if (model.pkid == 0)
         {
             tbl_PIOC_Arrival_DataMaster abc = new tbl_PIOC_Arrival_DataMaster();
             if (MED != null)
             {
                 abc.MedicalCertificate = web.Storefile(MED, 3);
             }
             if (CHR != null)
             {
                 abc.CharacterCertificate = web.Storefile(CHR, 3);
             }
             if (SIG != null)
             {
                 abc.SignofIndividual = web.Storefile(SIG, 3);
             }
             abc.Course_fkid      = model.Course_fkid;
             abc.Division_fkid    = model.Division_fkid;
             abc.Force_fkid       = model.Force_fkid;
             abc.Session_fkid     = model.Session_fkid;
             abc.Student_fkid     = model.Student_fkid;
             abc.ChestNo          = model.ChestNo;
             abc.ArmyNo           = model.ArmyNo;
             abc.Rank             = model.Rank;
             abc.ParentUnit       = model.ParentUnit;
             abc.Records          = model.Records;
             abc.NCCUnit          = model.NCCUnit;
             abc.DateOfArrival    = model.DateOfArrival;
             abc.DTE              = model.DTE;
             abc.DateofDEP        = model.DateofDEP;
             abc.MoveOrder        = model.MoveOrder;
             abc.IdentityCard     = model.IdentityCard;
             abc.MobileNo         = model.MobileNo;
             abc.IMEIno           = model.IMEIno;
             abc.AddedDate        = DateTime.Now;
             abc.LastModifiedDate = DateTime.Now;
             _PIOCMaster.Add(abc);
         }
         else
         {
             tbl_PIOC_Arrival_DataMaster abc = _PIOCMaster.Get(model.pkid);
             if (CHR != null)
             {
                 if (model.CharacterCertificate != null)
                 {
                     web.DeleteImage(model.CharacterCertificate);
                 }
                 abc.CharacterCertificate = web.Storefile(CHR, 3);
             }
             if (MED != null)
             {
                 if (model.MedicalCertificate != null)
                 {
                     web.DeleteImage(model.MedicalCertificate);
                 }
                 abc.MedicalCertificate = web.Storefile(MED, 3);
             }
             if (SIG != null)
             {
                 if (model.SignofIndividual != null)
                 {
                     web.DeleteImage(model.SignofIndividual);
                 }
                 abc.SignofIndividual = web.Storefile(SIG, 3);
             }
             abc.Course_fkid      = model.Course_fkid;
             abc.Division_fkid    = model.Division_fkid;
             abc.Force_fkid       = model.Force_fkid;
             abc.Session_fkid     = model.Session_fkid;
             abc.Student_fkid     = model.Student_fkid;
             abc.ChestNo          = model.ChestNo;
             abc.ArmyNo           = model.ArmyNo;
             abc.Rank             = model.Rank;
             abc.ParentUnit       = model.ParentUnit;
             abc.Records          = model.Records;
             abc.NCCUnit          = model.NCCUnit;
             abc.DateOfArrival    = model.DateOfArrival;
             abc.DTE              = model.DTE;
             abc.DateofDEP        = model.DateofDEP;
             abc.MoveOrder        = model.MoveOrder;
             abc.IdentityCard     = model.IdentityCard;
             abc.MobileNo         = model.MobileNo;
             abc.IMEIno           = model.IMEIno;
             abc.AddedDate        = model.AddedDate;
             abc.LastModifiedDate = DateTime.Now;
             _PIOCMaster.Update(abc);
         }
         return(RedirectToAction("PIOCMaster", "ArrivalSchema"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         return(RedirectToAction("PIOCMaster", "ArrivalSchema"));
     }
 }