Пример #1
0
        public Plan.Update FromRequest(Request.Update request)
        {
            var workPlan = new Plan.Recode(request.Requester, request.WorkDate.ToShortDateString(), request.WorkTime.ToString());
            var restPlan = new Plan.Recode(request.Requester, request.RestDate.ToShortDateString(), request.RestTime.ToString());

            return(new Plan.Update(workPlan, restPlan));
        }
Пример #2
0
        private Option <int> SelectPlanId(OleDbTransaction transaction, Plan.Recode plan)
        {
            var tableName = "`plan`";

            var where = $"`requester` = '{plan.Requester}' and `date` = #{plan.Date}# and `time` = '{plan.Time}'";
            var order   = $"SELECT `id` FROM {tableName} WHERE {where}";
            var command = new OleDbCommand(order, Connection);

            command.Transaction = transaction;
            Console.WriteLine(order);
            return(command.OptionalExecuteScalar <int>().getOptRight());
        }
Пример #3
0
        private Option <int> Update(OleDbTransaction transaction, int id, Plan.Recode recode)
        {
            var tableName = "`plan`";
            var orderText =
                $" UPDATE {tableName}"
                + $" SET    `date` = #{recode.Date}#, `time` = '{recode.Time}'"
                + $" WHERE  `id` = {id}";
            var command = new OleDbCommand(orderText, Connection);

            command.Transaction = transaction;
            return(command.OptionalExecuteNonQuery().getOptRight());
        }
Пример #4
0
        private Option <int> InsertRestPlan(OleDbTransaction transaction, Plan.Recode restPlan)
        {
            var tableName = "`plan`";
            var rows      = "`requester`, `date`, `time`, `type`";
            var values    = $"'{restPlan.Requester}', #{restPlan.Date}#, '{restPlan.Time}', 'rest'";
            var order     = $"INSERT INTO {tableName}({rows}) VALUES ({values})";
            var command   = new OleDbCommand(order, Connection);

            command.Transaction = transaction;
            var result = command.OptionalExecuteNonQuery();

            if (result.isLeft())
            {
                return(new None <int>());
            }
            return(OleDbExtension.SelectIDENTITY(Connection, transaction));
        }