Exemplo n.º 1
0
        public static Common.Models.Tasks.TaskTime RelateTask(Common.Models.Timing.Time timeModel,
                                                              long taskId, Common.Models.Account.Users creator)
        {
            Common.Models.Tasks.TaskTime taskTime = new Common.Models.Tasks.TaskTime()
            {
                Id   = Guid.NewGuid(),
                Task = new Common.Models.Tasks.Task()
                {
                    Id = taskId, IsStub = true
                },
                Time       = timeModel,
                Created    = DateTime.UtcNow,
                Modified   = DateTime.UtcNow,
                CreatedBy  = creator,
                ModifiedBy = creator
            };

            DBOs.Tasks.TaskTime dbo = Mapper.Map <DBOs.Tasks.TaskTime>(taskTime);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("INSERT INTO \"task_time\" (\"id\", \"task_id\", \"time_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Id, @TaskId, @TimeId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo);
            }

            return(taskTime);
        }
Exemplo n.º 2
0
 public static Common.Models.Tasks.TaskTime Create(
     Transaction t,
     Common.Models.Tasks.TaskTime model,
     Common.Models.Account.Users creator)
 {
     return(Create(model, creator, t.Connection, false));
 }
Exemplo n.º 3
0
        public static Common.Models.Tasks.TaskTime Create(
            Common.Models.Tasks.TaskTime model,
            Common.Models.Account.Users creator,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.Created   = model.Modified = DateTime.UtcNow;
            model.CreatedBy = model.ModifiedBy = creator;

            DBOs.Tasks.TaskTime dbo = Mapper.Map <DBOs.Tasks.TaskTime>(model);

            conn = DataHelper.OpenIfNeeded(conn);

            conn.Execute("INSERT INTO \"task_time\" (\"id\", \"task_id\", \"time_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                         "VALUES (@Id, @TaskId, @TimeId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                         dbo);

            DataHelper.Close(conn, closeConnection);

            return(model);
        }
Exemplo n.º 4
0
        public ActionResult AssignFastTime(Guid id)
        {
            // Id is TimeId
            long taskId;

            Common.Models.Tasks.TaskTime       model;
            ViewModels.Tasks.TaskTimeViewModel viewModel;
            Common.Models.Account.Users        currentUser;

            currentUser = Data.Account.Users.Get((Guid)Membership.GetUser().ProviderUserKey);

            taskId = long.Parse(Request["TaskId"]);

            model = new Common.Models.Tasks.TaskTime()
            {
                Created    = DateTime.Now,
                Modified   = DateTime.Now,
                CreatedBy  = currentUser,
                ModifiedBy = currentUser
            };
            model.Task        = Data.Tasks.Task.Get(taskId);
            model.Time        = Data.Timing.Time.Get(id);
            model.Time.Worker = Data.Contacts.Contact.Get(model.Time.Worker.Id.Value);

            viewModel             = Mapper.Map <ViewModels.Tasks.TaskTimeViewModel>(model);
            viewModel.Task        = Mapper.Map <ViewModels.Tasks.TaskViewModel>(model.Task);
            viewModel.Time        = Mapper.Map <ViewModels.Timing.TimeViewModel>(model.Time);
            viewModel.Time.Worker = Mapper.Map <ViewModels.Contacts.ContactViewModel>(model.Time.Worker);

            return(View(viewModel));
        }
Exemplo n.º 5
0
        public static Common.Models.Tasks.TaskTime Create(Common.Models.Tasks.TaskTime model,
                                                          Common.Models.Account.Users creator)
        {
            if (!model.Id.HasValue)
            {
                model.Id = Guid.NewGuid();
            }
            model.Created   = model.Modified = DateTime.UtcNow;
            model.CreatedBy = model.ModifiedBy = creator;

            DBOs.Tasks.TaskTime dbo = Mapper.Map <DBOs.Tasks.TaskTime>(model);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("INSERT INTO \"task_time\" (\"id\", \"task_id\", \"time_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Id, @TaskId, @TimeId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo);
            }

            return(model);
        }
Exemplo n.º 6
0
        public static Common.Models.Tasks.TaskTime RelateTask(
            Common.Models.Timing.Time timeModel,
            long taskId,
            Common.Models.Account.Users creator,
            IDbConnection conn   = null,
            bool closeConnection = true)
        {
            Common.Models.Tasks.TaskTime taskTime = new Common.Models.Tasks.TaskTime()
            {
                Id   = Guid.NewGuid(),
                Task = new Common.Models.Tasks.Task()
                {
                    Id = taskId, IsStub = true
                },
                Time       = timeModel,
                Created    = DateTime.UtcNow,
                Modified   = DateTime.UtcNow,
                CreatedBy  = creator,
                ModifiedBy = creator
            };

            DBOs.Tasks.TaskTime dbo = Mapper.Map <DBOs.Tasks.TaskTime>(taskTime);

            conn = DataHelper.OpenIfNeeded(conn);

            if (conn.Execute("INSERT INTO \"task_time\" (\"id\", \"task_id\", \"time_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                             "VALUES (@Id, @TaskId, @TimeId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                             dbo) > 0)
            {
                timeModel.Id = conn.Query <DBOs.Tasks.TaskTime>("SELECT currval(pg_get_serial_sequence('task_time', 'id')) AS \"id\"").Single().Id;
            }

            DataHelper.Close(conn, closeConnection);

            return(taskTime);
        }
Exemplo n.º 7
0
        public static Common.Models.Tasks.TaskTime RelateTask(Common.Models.Timing.Time timeModel,
            long taskId, Common.Models.Account.Users creator)
        {
            Common.Models.Tasks.TaskTime taskTime = new Common.Models.Tasks.TaskTime()
            {
                Id = Guid.NewGuid(),
                Task = new Common.Models.Tasks.Task() { Id = taskId, IsStub = true },
                Time = timeModel,
                Created = DateTime.UtcNow,
                Modified = DateTime.UtcNow,
                CreatedBy = creator,
                ModifiedBy = creator
            };

            DBOs.Tasks.TaskTime dbo = Mapper.Map<DBOs.Tasks.TaskTime>(taskTime);

            using (IDbConnection conn = Database.Instance.GetConnection())
            {
                conn.Execute("INSERT INTO \"task_time\" (\"id\", \"task_id\", \"time_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                    "VALUES (@Id, @TaskId, @TimeId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                    dbo);
            }

            return taskTime;
        }
Exemplo n.º 8
0
        public static Common.Models.Tasks.TaskTime RelateTask(
            Common.Models.Timing.Time timeModel,
            long taskId, 
            Common.Models.Account.Users creator,
            IDbConnection conn = null,
            bool closeConnection = true)
        {
            Common.Models.Tasks.TaskTime taskTime = new Common.Models.Tasks.TaskTime()
            {
                Id = Guid.NewGuid(),
                Task = new Common.Models.Tasks.Task() { Id = taskId, IsStub = true },
                Time = timeModel,
                Created = DateTime.UtcNow,
                Modified = DateTime.UtcNow,
                CreatedBy = creator,
                ModifiedBy = creator
            };

            DBOs.Tasks.TaskTime dbo = Mapper.Map<DBOs.Tasks.TaskTime>(taskTime);

            conn = DataHelper.OpenIfNeeded(conn);

            if (conn.Execute("INSERT INTO \"task_time\" (\"id\", \"task_id\", \"time_id\", \"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " +
                "VALUES (@Id, @TaskId, @TimeId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)",
                dbo) > 0)
                timeModel.Id = conn.Query<DBOs.Tasks.TaskTime>("SELECT currval(pg_get_serial_sequence('task_time', 'id')) AS \"id\"").Single().Id;

            DataHelper.Close(conn, closeConnection);

            return taskTime;
        }
Exemplo n.º 9
0
        public ActionResult AssignFastTime(Guid id)
        {
            // Id is TimeId
            long taskId;
            Common.Models.Tasks.TaskTime model;
            ViewModels.Tasks.TaskTimeViewModel viewModel;
            Common.Models.Account.Users currentUser;

            currentUser = Data.Account.Users.Get((Guid)Membership.GetUser().ProviderUserKey);

            taskId = long.Parse(Request["TaskId"]);

            model = new Common.Models.Tasks.TaskTime()
            {
                Created = DateTime.Now,
                Modified = DateTime.Now,
                CreatedBy = currentUser,
                ModifiedBy = currentUser
            };
            model.Task = Data.Tasks.Task.Get(taskId);
            model.Time = Data.Timing.Time.Get(id);
            model.Time.Worker = Data.Contacts.Contact.Get(model.Time.Worker.Id.Value);

            viewModel = Mapper.Map<ViewModels.Tasks.TaskTimeViewModel>(model);
            viewModel.Task = Mapper.Map<ViewModels.Tasks.TaskViewModel>(model.Task);
            viewModel.Time = Mapper.Map<ViewModels.Timing.TimeViewModel>(model.Time);
            viewModel.Time.Worker = Mapper.Map<ViewModels.Contacts.ContactViewModel>(model.Time.Worker);

            return View(viewModel);
        }