Example #1
0
 public static ResultObject GetMostProfitableList(int?month)
 {
     try
     {
         if (month == null)
         {
             throw new BusinessException(Errors.Codes.DateEmpty);
         }
         ABCEntities                   context                 = new ABCEntities();
         List <MODEL_DETAILS>          modelsDetails           = context.MODEL_DETAILS.AsNoTracking().ToList();
         List <ModelWithCostAndProfit> modelsWithCostAndProfit = GeneralWrapper.CalculateCostsAndProfits(month.Value, modelsDetails);
         ModelWithCostAndProfit        modelWithMostProfit     = modelsWithCostAndProfit.OrderByDescending(m => m.Profit).FirstOrDefault();
         List <ModelWithCostAndProfit> result = new List <ModelWithCostAndProfit>();
         if (modelWithMostProfit != null)
         {
             result = modelsWithCostAndProfit.Where(m => m.Profit == modelWithMostProfit.Profit).ToList();
         }
         return(BasicWrapper.SuccessResult(result));
     }
     catch (BusinessException exp)
     {
         return(BasicWrapper.ErrorResult(exp.Code, exp.Message));
     }
     catch (Exception exp)
     {
         return(BasicWrapper.GeneralErrorResult());
     }
 }
Example #2
0
 public static ResultObject GetColors()
 {
     try
     {
         ABCEntities  context = new ABCEntities();
         List <COLOR> colors  = context.COLOR.AsNoTracking().ToList();
         return(BasicWrapper.SuccessResult(GeneralWrapper.Colors(colors)));
     }
     catch (BusinessException exp)
     {
         return(BasicWrapper.ErrorResult(exp.Code, exp.Message));
     }
     catch (Exception exp)
     {
         return(BasicWrapper.GeneralErrorResult());
     }
 }
Example #3
0
 public static ResultObject GetTypes()
 {
     try
     {
         ABCEntities context = new ABCEntities();
         List <TYPE> types   = context.TYPE.AsNoTracking().ToList();
         return(BasicWrapper.SuccessResult(GeneralWrapper.Types(types)));
     }
     catch (BusinessException exp)
     {
         return(BasicWrapper.ErrorResult(exp.Code, exp.Message));
     }
     catch (Exception exp)
     {
         return(BasicWrapper.GeneralErrorResult());
     }
 }
Example #4
0
 public static ResultObject GetProfitableList(int?month)
 {
     try
     {
         if (month == null)
         {
             throw new BusinessException(Errors.Codes.DateEmpty);
         }
         ABCEntities                   context                 = new ABCEntities();
         List <MODEL_DETAILS>          modelsDetails           = context.MODEL_DETAILS.AsNoTracking().ToList();
         List <ModelWithCostAndProfit> modelsWithCostAndProfit = GeneralWrapper.CalculateCostsAndProfits(month.Value, modelsDetails);
         List <Model>                  result = new List <Model>();
         foreach (var model in modelsWithCostAndProfit)
         {
             if (model.Profit <= 0)
             {
                 continue;
             }
             result.Add(new Model()
             {
                 ColorId       = model.ColorId,
                 ColorName     = model.ColorName,
                 Id            = model.Id,
                 IsConvertible = model.IsConvertible,
                 Price         = model.Price,
                 TypeId        = model.TypeId,
                 TypeName      = model.TypeName
             });
         }
         return(BasicWrapper.SuccessResult(result));
     }
     catch (BusinessException exp)
     {
         return(BasicWrapper.ErrorResult(exp.Code, exp.Message));
     }
     catch (Exception exp)
     {
         return(BasicWrapper.GeneralErrorResult());
     }
 }