Esempio n. 1
0
        public string Add(projectVersion newProjectVersion)
        {
            string ret = "";

            db.projectVersion.Add(newProjectVersion);
            return(ret);
        }
Esempio n. 2
0
        public string Delete(projectVersion deleteProjectVersion)
        {
            string ret = "";

            db.Entry(deleteProjectVersion).State = EntityState.Deleted;
            return(ret);
        }
Esempio n. 3
0
        public string Delete(int projectVersionId)
        {
            string         ret = "";
            projectVersion deleteProjectVersion =
                getById(projectVersionId.ToString());

            ret = Delete(deleteProjectVersion);
            return(ret);
        }
Esempio n. 4
0
        public string Delete(string projectId, string version)
        {
            string         ret;
            projectVersion deleteProjectVersion =
                getProjectVersion(projectId, version);

            ret = Delete(deleteProjectVersion);
            return(ret);
        }
Esempio n. 5
0
        public projectVersion getById(string projectVersionIdS)
        {
            projectVersion ret = null;
            int            projectVersionId = 0;

            if (int.TryParse(projectVersionIdS, out projectVersionId))
            {
                var qry = (from a in db.projectVersion
                           where a.projectVersionId == projectVersionId
                           select a).FirstOrDefault();
                ret = qry;
            }
            return(ret);
        }
Esempio n. 6
0
        public string Update(projectVersion updateProjectVersion)
        {
            string ret             = "";
            var    aProjectVersion = db.projectVersion.SingleOrDefault(
                x => x.projectId == updateProjectVersion.projectId &&
                x.version == updateProjectVersion.version);

            if (aProjectVersion != null)
            {
                aProjectVersion = reflectionUtl.assign <projectVersion
                                                        , projectVersion>(aProjectVersion,
                                                                          updateProjectVersion);
                db.Entry(aProjectVersion).State = EntityState.Modified;
            }
            else
            {
                throw new Exception($"project version (" +
                                    $"projectId:{updateProjectVersion.projectId}, " +
                                    $"version:{updateProjectVersion.version}) " +
                                    $"not found");
            }
            return(ret);
        }
Esempio n. 7
0
        public ActionResult Index(projectVersionsViewModel viewModel)
        {
            ActionResult ar;
            var          multiSelect = Request.Form["multiSelect"];

            ViewBag.projectList = PMdropdownOption.projectList();
            viewModel.clearMsg();
            tblProjectVersion           tpv = new tblProjectVersion();
            projectVersionEditViewModel tmpVM;

            switch (viewModel.cmd)
            {
            case "query":
                viewModel.errorMsg = queryProjectVersions(ref viewModel);
                ar = View(viewModel);
                break;

            case "add":
                tmpVM            = new projectVersionEditViewModel();
                tmpVM.pageStatus = (int)PAGE_STATUS.ADD;
                TempData["projectVersionEditViewModel"] = tmpVM;
                ar = RedirectToAction("AddUpdate");
                return(ar);

            case "update":
                projectVersion pv = tpv.getById(viewModel.singleSelect);
                if (pv != null)
                {
                    tmpVM            = new projectVersionEditViewModel();
                    tmpVM.editModel  = pv;
                    tmpVM.pageStatus = (int)PAGE_STATUS.EDIT;
                    TempData["projectVersionEditViewModel"] = tmpVM;
                    ar = RedirectToAction("AddUpdate");
                    return(ar);
                }
                viewModel.errorMsg = "error reading this project version";
                ar = View(viewModel);
                break;

            case "delete":
                //undone !!... (3) delete project delete article also
                if (string.IsNullOrWhiteSpace(multiSelect))
                {
                    viewModel.errorMsg = "please select project version to delete";
                }
                else
                {
                    string[] selected = multiSelect.Split(',');
                    foreach (string projectVersionS in selected.ToList())
                    {
                        int projectVersionId;
                        if (!int.TryParse(projectVersionS, out projectVersionId))
                        {
                            continue;
                        }
                        viewModel.errorMsg += tpv.Delete(projectVersionId);
                    }
                    viewModel.errorMsg += tpv.SaveChanges();
                    if (string.IsNullOrWhiteSpace(viewModel.errorMsg))
                    {
                        viewModel.successMsg = "successfully deleted";
                    }
                }
                viewModel.errorMsg = queryProjectVersions(ref viewModel);
                ar = View(viewModel);
                break;

            default:
                ar = View(viewModel);
                break;
            }
            return(ar);
        }
Esempio n. 8
0
 public projectVersionEditViewModel()
 {
     editModel = new projectVersion();
 }