public ActionResult CreateSubRelease(ContinousIntegration.Models.NewSubReleaseModel tsubrelease, string Command)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_CreateSubRelease", tsubrelease));
            }
            else
            {
                T_SubReleases Obj = new T_SubReleases();
                Obj.C_SubReleaseName = tsubrelease.C_SubReleaseName;
                Obj.C_SubReleaseID   = tsubrelease.C_SubReleaseID;
                Obj.C_ReleaseID      = tsubrelease.C_ReleaseID;
                Obj.C_StatusID       = tsubrelease.C_StatusID;
                Obj.C_LastModified   = DateTime.Now;

                bool IsSuccess = srobjModel.AddSubRelease(Obj);
                if (IsSuccess)
                {
                    TempData["OperStatus"] = "Sub-Release added successfully";
                    ModelState.Clear();
                    return(RedirectToAction("SearchSubRelease", "ManageProjects"));
                }
            }

            return(PartialView("_CreateSubRelease"));
        }
        public List <NewSubReleaseModel> GetSubReleasePage(int pageNumber, int pageSize, string searchCriteria)
        {
            if (pageNumber < 1)
            {
                pageNumber = 1;
            }


            var RequiredSubReleaseModel = (from a in entities.T_Releases
                                           join b in entities.T_SubReleases
                                           on a.C_ReleaseID equals b.C_ReleaseID
                                           join c in entities.T_Status
                                           on b.C_StatusID equals c.C_StatusID
                                           join d in entities.T_Streams
                                           on a.C_StreamID equals d.C_StreamID
                                           join e in entities.T_Projects
                                           on d.C_ProjectID equals e.C_ProjectID
                                           select new
            {
                a.C_ReleaseID,
                a.C_ReleaseName,
                b.C_SubReleaseID,
                b.C_SubReleaseName,
                b.C_StatusID,
                b.C_LastModified,
                c.C_StatusName,
                e.C_ProjectID,
                e.C_ProjectName,
                d.C_StreamID, d.C_StreamName
            })
                                          .ToList();

            //Populate NewSubReleaseModel with the required properties

            List <NewSubReleaseModel> Subrelease = new List <NewSubReleaseModel>();

            NewSubReleaseModel newobj;

            foreach (var item in RequiredSubReleaseModel)
            {
                newobj                  = new NewSubReleaseModel();
                newobj.C_ReleaseID      = item.C_ReleaseID;
                newobj.C_ReleaseName    = item.C_ReleaseName;
                newobj.C_SubReleaseName = item.C_SubReleaseName;
                newobj.C_SubReleaseID   = item.C_SubReleaseID;
                newobj.C_StatusID       = item.C_StatusID;
                newobj.C_StatusName     = item.C_StatusName;
                newobj.C_LastModified   = item.C_LastModified;
                newobj.C_ProjectID      = item.C_ProjectID;
                newobj.C_ProjectName    = item.C_ProjectName;
                newobj.C_StreamID       = item.C_StreamID;
                newobj.C_StreamName     = item.C_StreamName;

                Subrelease.Add(newobj);
            }
            return(Subrelease);
        }
        public ActionResult UpdateSubRelease(ContinousIntegration.Models.NewSubReleaseModel tsubrelease, string Command)
        {
            bool IsSuccess = srobjModel.UpdateSubRelease(tsubrelease);

            if (IsSuccess)
            {
                TempData["OperStatus"] = "Sub-Release updated successfully";
                ModelState.Clear();
                return(RedirectToAction("SearchSubRelease", "ManageProjects"));
            }


            return(PartialView("_EditSubRelease"));
        }
        //To update Sub Release details
        public bool UpdateSubRelease(NewSubReleaseModel tsubrelease)
        {
            try
            {
                var subrelease = entities.T_SubReleases.FirstOrDefault(x => x.C_SubReleaseID.Equals(tsubrelease.C_SubReleaseID));

                //Populate T_SubReleases with NewSubRelease Model

                subrelease.C_ReleaseID      = tsubrelease.C_ReleaseID;
                subrelease.C_SubReleaseID   = tsubrelease.C_SubReleaseID;
                subrelease.C_SubReleaseName = tsubrelease.C_SubReleaseName;
                subrelease.C_StatusID       = tsubrelease.C_StatusID;
                subrelease.C_LastModified   = DateTime.Now;

                entities.T_SubReleases.AddOrUpdate(subrelease);
                entities.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
        /// <summary>
        /// Method to populate the edit popup
        /// </summary>
        /// <param name="page"></param>
        /// <param name="sort"></param>
        /// <param name="sortDir"></param>
        /// <returns></returns>
        //Edit SubRelease
        public ActionResult EditSubRelease(int subreleaseId)
        {
            ContinuousIntegrationEntities ci = new ContinuousIntegrationEntities();
            var data = (from a in ci.T_Projects
                        join b in ci.T_Streams
                          on a.C_ProjectID equals b.C_ProjectID
                        join c in ci.T_Releases
                        on b.C_StreamID equals c.C_StreamID
                        join d in ci.T_SubReleases
                          on c.C_ReleaseID equals d.C_ReleaseID
                        where subreleaseId == d.C_SubReleaseID
                        select new
                        {
                            a.C_ProjectID,
                            c.C_ReleaseID,
                            d.C_SubReleaseName,
                            d.C_SubReleaseID,
                            d.C_StatusID,
                            d.C_LastModified,
                            b.C_StreamID,
                            b.C_StreamName
                        }).FirstOrDefault();

            NewSubReleaseModel Obj;
            if (Request.IsAjaxRequest())
            {
                Obj = new NewSubReleaseModel();
                Obj.C_SubReleaseName = data.C_SubReleaseName;
                Obj.C_ReleaseID = data.C_ReleaseID;
                Obj.C_SubReleaseID = data.C_SubReleaseID;
                Obj.C_StatusID = data.C_StatusID;
                Obj.C_LastModified = data.C_LastModified;
                Obj.C_ProjectID = data.C_ProjectID;
                Obj.C_StreamID = data.C_StreamID;
                Obj.C_StreamName = data.C_StreamName;

                ViewBag.ProjectName = new SelectList(ci.T_Projects, "C_ProjectID", "C_ProjectName");
                ViewBag.ReleaseName = new SelectList(ci.T_Releases.Where(x=> x.C_StreamID.Equals(data.C_StreamID)), "C_ReleaseID", "C_ReleaseName",ci.T_Releases.Where(x=> x.C_ReleaseID.Equals(data.C_ReleaseID)));
                ViewBag.StatusName = new SelectList(ci.T_Status, "C_StatusID", "C_StatusName");
                ViewBag.StreamName = new SelectList(ci.T_Streams.Where(x => x.C_ProjectID.Equals(data.C_ProjectID)), "C_StreamID", "C_StreamName", ci.T_Streams.Where(x => x.C_StreamID.Equals(data.C_StreamID)));
                ViewBag.IsUpdate = true;
                return View("_EditSubRelease", Obj);
            }
            else
                return View(data);
        }
        public List<NewSubReleaseModel> GetSubReleasePage(int pageNumber, int pageSize, string searchCriteria)
        {
            if (pageNumber < 1)
                pageNumber = 1;

            var RequiredSubReleaseModel = (from a in entities.T_Releases
                                           join b in entities.T_SubReleases
                                           on a.C_ReleaseID equals b.C_ReleaseID
                                           join c in entities.T_Status
                                           on b.C_StatusID equals c.C_StatusID
                                           join d in entities.T_Streams
                                           on a.C_StreamID equals d.C_StreamID
                                           join e in entities.T_Projects
                                           on d.C_ProjectID equals e.C_ProjectID
                                           select new
                                           {
                                               a.C_ReleaseID,
                                               a.C_ReleaseName,
                                               b.C_SubReleaseID,
                                               b.C_SubReleaseName,
                                               b.C_StatusID,
                                               b.C_LastModified,
                                               c.C_StatusName,
                                               e.C_ProjectID,
                                               e.C_ProjectName,
                                               d.C_StreamID,d.C_StreamName
                                           })
                                     .ToList();

            //Populate NewSubReleaseModel with the required properties

            List<NewSubReleaseModel> Subrelease = new List<NewSubReleaseModel>();

            NewSubReleaseModel newobj;
            foreach (var item in RequiredSubReleaseModel)
            {

                newobj = new NewSubReleaseModel();
                newobj.C_ReleaseID = item.C_ReleaseID;
                newobj.C_ReleaseName = item.C_ReleaseName;
                newobj.C_SubReleaseName = item.C_SubReleaseName;
                newobj.C_SubReleaseID = item.C_SubReleaseID;
                newobj.C_StatusID = item.C_StatusID;
                newobj.C_StatusName = item.C_StatusName;
                newobj.C_LastModified = item.C_LastModified;
                newobj.C_ProjectID = item.C_ProjectID;
                newobj.C_ProjectName = item.C_ProjectName;
                newobj.C_StreamID = item.C_StreamID;
                newobj.C_StreamName = item.C_StreamName;

                Subrelease.Add(newobj);
            }
            return Subrelease;
        }
        //To update Sub Release details
        public bool UpdateSubRelease(NewSubReleaseModel tsubrelease)
        {
            try
            {
                var subrelease = entities.T_SubReleases.FirstOrDefault(x => x.C_SubReleaseID.Equals(tsubrelease.C_SubReleaseID));

                //Populate T_SubReleases with NewSubRelease Model

                    subrelease.C_ReleaseID = tsubrelease.C_ReleaseID;
                    subrelease.C_SubReleaseID = tsubrelease.C_SubReleaseID;
                    subrelease.C_SubReleaseName = tsubrelease.C_SubReleaseName;
                    subrelease.C_StatusID = tsubrelease.C_StatusID;
                    subrelease.C_LastModified = DateTime.Now;

                    entities.T_SubReleases.AddOrUpdate(subrelease);
                entities.SaveChanges();
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }