public Acheivement InsertAcheivement(Acheivement acheivement)
        {
            var inserted = iTIDataEntities.Acheivements.Add(acheivement);

            iTIDataEntities.SaveChanges();
            return(inserted);
        }
Example #2
0
 public ActionResult Create(AcheivementModel acheivementModel)
 {
     try
     {
         Acheivement acheivement = new Acheivement
         {
             ID          = acheivementModel.ID,
             NameofAward = acheivementModel.NameofAward,
             Remarks     = acheivementModel.Remarks,
             SchemeName  = acheivementModel.SchemeName,
             WonBy       = acheivementModel.WonBy,
             Year        = acheivementModel.Year
         };
         if (ModelState.IsValid)
         {
             if (acheivement.ID > 0)
             {
                 acheivementRepository.UpdateAcheivement(acheivement);
             }
             else
             {
                 acheivementRepository.InsertAcheivement(acheivement);
             }
         }
         else
         {
             return(View(acheivementModel));
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View(acheivementModel));
     }
 }
        public ActionResult UpdateAcheivement(Acheivement ach)
        {
            if (Session["EmpID"] != null)
            {
                try
                {
                    ach.AcheivementDate = DateTimeHelper.yyyy_mm_dd(ach.AcheivementDate);
                }
                catch (FormatException)
                {
                    ModelState.AddModelError("AcheivementDate", "Invalid Format");
                }
                if (ModelState.IsValid)
                {
                    ach.EmployeeID = Convert.ToInt32(Session["EmpId"]);
                    ach.UpdateAcheivement();
                }
                else
                {
                    ach.EmployeeID = Convert.ToInt32(Session["EmpId"]);
                    ViewBag.data   = ach.GetAcheivement();
                    return(View("Index", ach));
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index", "LogIn"));
            }
        }
Example #4
0
        public ActionResult Delete(int id = 0)
        {
            Acheivement acheivement = new Acheivement();

            if (id > 0)
            {
                acheivementRepository.DeleteAcheivements(id);
            }
            return(RedirectToAction("Index"));
        }
        public JsonResult GetAcheivement(int AcheivementID)
        {
            Acheivement ac = new Acheivement()
            {
                EmployeeID = Convert.ToInt32(Session["EmpId"]), AcheivementId = AcheivementID
            };

            System.Data.DataSet x = ac.GetJsonAcheivement();
            string z = JsonConvert.SerializeObject(x);

            return(Json(z, JsonRequestBehavior.AllowGet));
        }
 public ActionResult DeleteAcheivement(int AcheivementId)
 {
     if (Session["EmpID"] != null)
     {
         Acheivement ac = new Acheivement()
         {
             EmployeeID = Convert.ToInt32(Session["EmpId"]), AcheivementId = AcheivementId
         };
         ac.DeleteAcheivement();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index", "LogIn"));
     }
 }
 public ActionResult DownloadFile(int FileID)
 {
     if (Session["EmpID"] != null)
     {
         Acheivement ac = new Acheivement()
         {
             EmployeeID = Convert.ToInt32(Session["EmpId"]), FileId = FileID
         };
         System.Data.DataSet ds = ac.DownloadFile();
         return(File((Byte[])ds.Tables[0].Rows[0][0], System.Web.MimeMapping.GetMimeMapping(ds.Tables[0].Rows[0][1].ToString()), ds.Tables[0].Rows[0][1].ToString()));
     }
     else
     {
         return(RedirectToAction("Index", "LogIn"));
     }
 }
        // GET: Acheivement
        public ActionResult Index()
        {
            if (Session["EmpID"] != null)
            {
                Acheivement ac = new Acheivement()
                {
                    EmployeeID = Convert.ToInt32(Session["EmpId"])
                };
                ViewBag.data = ac.GetAcheivement();

                return(View());
            }
            else
            {
                return(RedirectToAction("Index", "LogIn"));
            }
        }
Example #9
0
        public ActionResult Create(int id = 0)
        {
            Acheivement acheivement = new Acheivement();

            if (id > 0)
            {
                acheivement = acheivementRepository.GetAcheivementById(id);
            }
            AcheivementModel acheivementModel = new AcheivementModel
            {
                ID          = acheivement.ID,
                NameofAward = acheivement.NameofAward,
                Remarks     = acheivement.Remarks,
                SchemeName  = acheivement.SchemeName,
                WonBy       = acheivement.WonBy,
                Year        = acheivement.Year
            };

            return(View(acheivementModel));
        }
 public Acheivement UpdateAcheivement(Acheivement acheivement)
 {
     iTIDataEntities.Entry(acheivement).State = EntityState.Modified;
     iTIDataEntities.SaveChanges();
     return(acheivement);
 }