Exemplo n.º 1
0
        public CreateKpiTargetsResponse Creates(CreateKpiTargetsRequest request)
        {
            var response = new CreateKpiTargetsResponse();

            try
            {
                if (request.KpiTargets.Count > 0)
                {
                    foreach (var kpiTarget in request.KpiTargets)
                    {
                        var data = kpiTarget.MapTo <KpiTarget>();
                        data.Kpi = DataContext.Kpis.FirstOrDefault(x => x.Id == kpiTarget.KpiId);
                        DataContext.KpiTargets.Add(data);
                        DataContext.SaveChanges();
                    }
                    response.IsSuccess = true;
                    response.Message   = "KPI Target has been added successfully";
                }
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }
            return(response);
        }
Exemplo n.º 2
0
 public CreateKpiTargetsResponse Creates(CreateKpiTargetsRequest request)
 {
     var response = new CreateKpiTargetsResponse();
     try
     {
         if (request.KpiTargets.Count > 0)
         {
             foreach (var kpiTarget in request.KpiTargets)
             {
                 var data = kpiTarget.MapTo<KpiTarget>();
                 data.Kpi = DataContext.Kpis.FirstOrDefault(x => x.Id == kpiTarget.KpiId);
                 DataContext.KpiTargets.Add(data);
                 DataContext.SaveChanges();
             }
             response.IsSuccess = true;
             response.Message = "KPI Target has been added successfully";
         }
     }
     catch (DbUpdateException dbUpdateException)
     {
         response.Message = dbUpdateException.Message;
     }
     return response;
 }