コード例 #1
0
        private int SaveTimeIt(TimeItModels.NewTimeIt Model)
        {
            int siteCoID = siteusercompanyid;

            ProjectTimeIts newTimeIt = new ProjectTimeIts()
            {
                TimeItID         = Model.TimeItID ?? 0,
                SiteCoID         = siteusercompanyid,
                ProjectID        = Model.ProjectID,
                SiteUserID       = Model.ResourceID ?? siteuserid,
                Subject          = Model.Task,
                Hours            = Model.Hours,
                TimeItDate       = Model.Date,
                TimeItTime       = Model.Date.HasValue ? Model.Date.Value.TimeOfDay : new TimeSpan(),
                Notes            = Model.Notes,
                ProjectStageID   = Model.StageID,
                ProjectPayTypeID = Model.PaytypeID
            };

            if (newTimeIt.TimeItID == 0)
            {
                newTimeIt.StatusID = repo.GetDefaultActivityStatusId(siteusercompanyid);
            }

            int timeItID = repo.SaveTimeIt(newTimeIt);

            if (timeItID > 0)
            {
                return(timeItID);
            }
            else
            {
                return(0);
            }
        }
コード例 #2
0
        public ActionResult Edit(int?id, int contactid)
        {
            ViewBag.Jobs = new SelectList(db.GetJobsByContactID_WithLockFalse(contactid), "ViewID", "Project");

            var siteUsers = db.SiteUsers.Where(p => p.SiteCoID == siteusercompanyid).OrderBy(p => p.UserDisplayName);

            ViewBag.Resource = new SelectList(siteUsers, "SiteUserID", "UserDisplayName");

            TimeItModels.NewTimeIt model  = new TimeItModels.NewTimeIt();
            ProjectTimeIts         timeIt = db.ProjectTimeIts.Where(p => p.TimeItID == (id ?? 0)).FirstOrDefault();

            if (timeIt != null)
            {
                model = new TimeItModels.NewTimeIt()
                {
                    TimeItID   = timeIt.TimeItID,
                    Date       = timeIt.TimeItDate.HasValue ? timeIt.TimeItDate.Value.Add(timeIt.TimeItTime ?? new TimeSpan()) : timeIt.TimeItDate,
                    Hours      = timeIt.Hours,
                    Notes      = timeIt.Notes,
                    PaytypeID  = timeIt.ProjectPayTypeID,
                    ProjectID  = timeIt.ProjectID,
                    ResourceID = timeIt.SiteUserID,
                    StageID    = timeIt.ProjectStageID,
                    Task       = timeIt.Subject
                };
            }

            var projectData = FetchProjectData(timeIt.ProjectID ?? 0);

            ViewBag.Stages   = new SelectList(projectData.Item1.Select(p => new { p.ProjectStageID, p.StageName }), "ProjectStageID", "StageName", model.StageID);
            ViewBag.PayTypes = new SelectList(projectData.Item2.Select(p => new { p.PayTypeID, p.Pay_Type }), "PayTypeID", "Pay_Type", model.PaytypeID);

            return(View("_Edit", model));
        }