public ActionResult Create(JobCardDailyActivity model)
 {
     try
     {
         model.CreatedBy      = UserID.ToString();
         model.OrganizationId = OrganizationId;
         model.CreatedDate    = DateTime.Now;
         //if (ModelState.IsValid)
         //{
         JobCardDailyActivityRepository repo = new JobCardDailyActivityRepository();
         model.CreatedDate = DateTime.Now;
         int id = 0;
         if (model.isProjectBased == 0)
         {
             id = repo.InsertJobCardDailyActivity(model);
         }
         else
         {
             id = repo.InsertProjectDailyActivity(model);
         }
         if (id == 0)
         {
             TempData["error"] = "Some error occured while saving. Please try again.";
             return(View(model));
         }
         TempData["success"]        = "Saved Successfully.";
         TempData["previousAction"] = "Create";
         return(RedirectToAction("Details", new { id = id, type = model.isProjectBased }));
         //}
         //else
         //{
         //    return View("Create", new { Id = model.JobCardId });
         //}
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occured. Please try again.";
         return(View(model));
     }
 }
 public ActionResult Details(int id = 0, int type = 0)//JobCardDailyActivityId
 {
     if (id == 0)
     {
         TempData["error"] = "That was an invalid/unknown request";
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         var model = new JobCardDailyActivityRepository().GetJobCardDailyActivity(id);
         if (model == null)
         {
             TempData["error"] = "Could not find the requested data. Please try again.";
         }
         return(View(model));
     }
     catch (Exception)
     {
         TempData["error"] = "Some error occurred. Please try again.";
     }
     return(RedirectToAction("PreviousList"));
 }
        public ActionResult Delete(int Id)
        {
            try
            {
                if (Id == 0)
                {
                    return(RedirectToAction("PreviousList"));
                }
                JobCardDailyActivity model = new JobCardDailyActivityRepository().DeleteJobCardDailyActivity(Id);
                if (model != null)
                {
                    string filepath;
                    try
                    {
                        filepath = Server.MapPath("~/App_Images/" + model.Image1);
                        if (System.IO.File.Exists(filepath))
                        {
                            System.IO.File.Delete(filepath);
                        }
                    }
                    catch { }

                    try
                    {
                        filepath = Server.MapPath("~/App_Images/" + model.Image2);
                        if (System.IO.File.Exists(filepath))
                        {
                            System.IO.File.Delete(filepath);
                        }
                    }
                    catch { }

                    try
                    {
                        filepath = Server.MapPath("~/App_Images/" + model.Image3);
                        if (System.IO.File.Exists(filepath))
                        {
                            System.IO.File.Delete(filepath);
                        }
                    }
                    catch { }

                    try
                    {
                        filepath = Server.MapPath("~/App_Images/" + model.Image4);
                        if (System.IO.File.Exists(filepath))
                        {
                            System.IO.File.Delete(filepath);
                        }
                    }
                    catch { }

                    TempData["success"] = "Deleted Successfully (" + model.JobCardDailyActivityRefNo + ")";
                    return(RedirectToAction("PreviousList"));
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                TempData["error"] = "Some error occured while deleting. Please try again.";
                return(RedirectToAction("Details", new { id = Id }));
            }
        }