public async Task <ICommandResult> Handle(ManufacturerManagementAddCommand mesage) { try { Manufacturer manufacturer = new Manufacturer(); manufacturer.Add(mesage); await _manufacturerService.AddToDb(manufacturer); ICommandResult result = new CommandResult() { Message = "", ObjectId = Convert.ToString(manufacturer.Id), Status = CommandResult.StatusEnum.Sucess }; return(result); } catch (Exception e) { e.Data["Param"] = mesage; ICommandResult result = new CommandResult() { Message = e.Message, Status = CommandResult.StatusEnum.Fail }; return(result); } }
public ActionResult Add(Manufacturer b) { b.Add(); return(View()); }
public bool LoadFormFile(string filePath) { if (File.Exists(filePath)) { StreamReader file = new StreamReader(filePath); //Read first line to check format string line = file.ReadLine(); if (line.Split(',').Length != 11) { return(false); } while ((line = file.ReadLine()) != null) { string[] lines = line.Split(','); if (lines.Length != 11) { Console.WriteLine("ERROR!: {0}", line); continue; } string manufac = lines[0]; string modelname = lines[1]; string devicename = lines[2]; string modelcode = lines[3]; string gpu = lines[4]; string formfactor = lines[5]; string sysonchip = lines[6]; string totalmem = lines[7]; string abis = lines[8]; string glesversion = lines[9]; string sdk = lines[10]; DeviceSpec deviceSpec = new DeviceSpec { GPU = gpu, FormFactor = formfactor, SystemOnChip = sysonchip, TotalMem = totalmem, ABIs = abis, OpenGLESVer = glesversion, SDKs = sdk }; ModelCode modelCode = new ModelCode { Name = modelcode, Spec = deviceSpec }; DeviceName deviceName = new DeviceName { Name = devicename, ModelCodes = new List <ModelCode> { modelCode } }; ModelName modelName = new ModelName { Name = modelname, DeviceNames = new List <DeviceName> { deviceName } }; // find manufac if (Manufacturers.Any(x => x.Name == manufac)) { Manufacturer Manufac = Manufacturers.First(x => x.Name == manufac); if (!Manufac.Add(modelName)) { Console.WriteLine("Warning!: Duplicate device {0}", line); Console.WriteLine("Warning!: at Manufacturers[{0}]", line, Manufacturers.IndexOf(Manufac)); } } else { Manufacturer newManufac = new Manufacturer { Name = manufac, ModelNames = new List <ModelName> { modelName } }; Manufacturers.Add(newManufac); } } } return(false); }