Пример #1
0
        public IHttpActionResult CreateNewChargingDetailTemplateByModel([FromUri] int customerId, [FromBody] InstructionTemplateDto template)
        {
            var fbaCustomers = _context.UpperVendors
                               .Where(x => x.DepartmentCode == "FBA");

            if (!template.IsApplyToAll)
            {
                var newTemplate = new InstructionTemplate
                {
                    IsApplyToMasterOrder = template.IsApplyToMasterOrder,
                    IsApplyToShipOrder   = template.IsApplyToShipOrder,
                    IsInstruction        = template.IsInstruction,
                    IsOperation          = template.IsOperation,
                    IsCharging           = template.IsCharging,
                    CreateBy             = _userName,
                    Description          = template.Description,
                    CreateDate           = DateTime.Now,
                    Status = template.IsCharging ? FBAStatus.WaitingForCharging : FBAStatus.NoNeedForCharging
                };

                var customerInDb = fbaCustomers.SingleOrDefault(x => x.Id == customerId);
                newTemplate.Customer = customerInDb;

                _context.InstructionTemplates.Add(newTemplate);
            }
            else
            {
                var templateList = new List <InstructionTemplate>();

                foreach (var f in fbaCustomers)
                {
                    var newTemplate = new InstructionTemplate
                    {
                        IsApplyToMasterOrder = template.IsApplyToMasterOrder,
                        IsApplyToShipOrder   = template.IsApplyToShipOrder,
                        IsInstruction        = template.IsInstruction,
                        IsOperation          = template.IsOperation,
                        IsCharging           = template.IsCharging,
                        CreateBy             = _userName,
                        Description          = template.Description,
                        CreateDate           = DateTime.Now,
                        Status = template.IsCharging ? FBAStatus.WaitingForCharging : FBAStatus.NoNeedForCharging
                    };

                    newTemplate.Customer = f;
                    templateList.Add(newTemplate);
                }

                _context.InstructionTemplates.AddRange(templateList);
            }

            _context.SaveChanges();

            var resultDto = Mapper.Map <ChargingItemDetail, ChargingItemDetailDto>(_context.ChargingItemDetails.OrderByDescending(x => x.Id).First());

            return(Created(Request.RequestUri + "/" + resultDto.Id, resultDto));
        }
Пример #2
0
 public void Run(Options options)
 {
     _grammar = Utils.LoadGrammar(options.Grammar);
     Directory.CreateDirectory(options.Output);
     foreach (var instruction in _grammar.Instructions)
     {
         var spirvInstruction = instruction.Value;
         //if (spirvInstruction.Kind == InstructionKind.Function ||
         //    spirvInstruction.Kind == InstructionKind.Executable)
         {
             var text = new InstructionTemplate(spirvInstruction).TransformText();
             Utils.SaveText(Path.Combine(options.Output, spirvInstruction.Name + ".cs"), text);
         }
     }
 }