Ejemplo n.º 1
0
        public static int Execute(CorrigoService service, int repairCategoryId, string displayAs)
        {
            // if repairCategoryId is 0, Repair Category instance will be created
            var repairCode = new RepairCode
            {
                ParentId  = repairCategoryId,
                DisplayAs = displayAs
            };

            var command = new CreateCommand {
                Entity = repairCode
            };
            var response = service.Execute(command) as OperationCommandResponse;

            var repairCodeId = response?.EntitySpecifier?.Id ?? 0;

            Debug.Print(response?.ErrorInfo?.Description
                        ?? $"Successfully created repair code {repairCodeId} for repair category with id {repairCategoryId}");

            if (response?.ErrorInfo != null)
            {
                throw new Exception(response?.ErrorInfo?.Description);
            }

            return(repairCodeId);
        }
Ejemplo n.º 2
0
        public TableData Query(RepairCode entity)
        {
            var result = new TableData();
            var data   = _app.Find(EntityToExpression <RepairCode> .GetExpressions(entity));

            GetData(data, result);
            result.count = data.Count();

            return(result);
        }
 public string Upd(RepairCode Table_entity)
 {
     try
     {
         _app.Upd(Table_entity);
     }
     catch (Exception ex)
     {
         Result.Status  = false;
         Result.Message = ex.Message;
     }
     return(JsonHelper.Instance.Serialize(Result));
 }
        public string GetTemplate()
        {
            var result = new TableData();
            List <RepairCode> listRepairCode = new List <RepairCode>();
            RepairCode        entity         = _app.FindSingle(u => u.Id > 0);

            if (entity != null)
            {
                listRepairCode.Add(entity);
            }
            else
            {
                listRepairCode.Add(new RepairCode());
            }

            result.data  = listRepairCode;
            result.count = listRepairCode.Count;

            return(JsonHelper.Instance.Serialize(result));
        }
Ejemplo n.º 5
0
        public Response ImportIn(IFormFile excelfile)
        {
            Response          result    = new Infrastructure.Response();
            List <RepairCode> exp       = imp.ConvertToModel <RepairCode>(excelfile);
            string            sErrorMsg = "";

            for (int i = 0; i < exp.Count; i++)
            {
                try
                {
                    RepairCode e = exp[i];
                    e.Id = null;
                    _app.Add(e);
                }
                catch (Exception ex)
                {
                    sErrorMsg     += "第" + (i + 2) + "行:" + ex.Message + "<br>";
                    result.Message = sErrorMsg;
                    break;
                }
            }
            if (sErrorMsg.Equals(string.Empty))
            {
                if (exp.Count == 0)
                {
                    sErrorMsg     += "没有发现有效数据, 请确定模板是否正确, 或是否有填充数据!";
                    result.Message = sErrorMsg;
                }
                else
                {
                    result.Message = "导入完成";
                }
            }
            else
            {
                result.Status  = false;
                result.Message = result.Message;
            }
            return(result);
        }
Ejemplo n.º 6
0
 public void Upd(RepairCode entity)
 {
     _app.Update(entity);
 }
Ejemplo n.º 7
0
 public void Ins(RepairCode entity)
 {
     _app.Add(entity);
 }
Ejemplo n.º 8
0
 public TableData Load(PageReq pageRequest, RepairCode entity)
 {
     return(_app.Load(pageRequest, entity));
 }
Ejemplo n.º 9
0
 public TableData ExportData(RepairCode entity)
 {
     return(_app.ExportData(entity));
 }
Ejemplo n.º 10
0
 public string Load(PageReq pageRequest, RepairCode entity)
 {
     return(JsonHelper.Instance.Serialize(_app.Load(pageRequest, entity)));
 }
Ejemplo n.º 11
0
 public string Export(RepairCode entity)
 {
     return(JsonHelper.Instance.Serialize(_app.ExportData(entity)));
 }