コード例 #1
0
ファイル: UserController.cs プロジェクト: frida169168/ctrlP
        public HttpResponseMessage allowdToPrint(Job job)
        {
            UserDTO user = UserLogic.Login(new UserDTO()
            {
                userTz = job.userTz
            });
            double?AmountToPay, balance;

            if (user != null)
            {
                balance     = UserLogic.getBalanceByUser(user);
                AmountToPay = JobLogic.CalaulateJob(job);
                if (AmountToPay - balance >= 0)
                {
                    PrintHistoryLogic.AddPrint(new PrintHistoryDTO()
                    {
                        userId      = user.userId,
                        datePrint   = DateTime.Now,
                        costPrint   = AmountToPay,
                        isColorFull = job.isColorFull,
                        sumOfPages  = job.numOfPages,
                        printerName = job.printerName
                    });
                    return(Request.CreateResponse(HttpStatusCode.OK, "OK"));
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Small_balance"));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, "User_doesnt_exist"));
        }