Exemplo n.º 1
0
        public string Update(SLAValues sla)
        {
            var existingSLAValue = context.SLAValues.Find(sla.ID);

            if (existingSLAValue != null)
            {
                try
                {
                    existingSLAValue.QuantityProcessed    = sla.QuantityProcessed;
                    existingSLAValue.QuantityOutsideofSLA = sla.QuantityOutsideofSLA;
                    existingSLAValue.UpdatedBy            = sla.UpdatedBy;
                    existingSLAValue.UpdatedDate          = sla.UpdatedDate;
                    context.SaveChanges();
                    return(existingSLAValue.ID.ToString());
                }catch (DbEntityValidationException ex)
                {
                    return(ex.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().ErrorMessage + ":" + ex.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().PropertyName);
                }
            }
            return("Error-No matching record");
        }
Exemplo n.º 2
0
 public string Insert(SLAValues slaValues)
 {
     try
     {
         var SLAValuesObj = new SLAValues()
         {
             SLAID                = slaValues.SLAID,
             ReportingDate        = slaValues.ReportingDate,
             QuantityProcessed    = slaValues.QuantityProcessed,
             QuantityOutsideofSLA = slaValues.QuantityOutsideofSLA,
             UpdatedBy            = slaValues.UpdatedBy,
             UpdatedDate          = slaValues.UpdatedDate
         };
         context.SLAValues.Add(SLAValuesObj);
         context.SaveChanges();
         return("1");
     }
     catch (DbEntityValidationException ex)
     {
         return(ex.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().ErrorMessage + ":" + ex.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().PropertyName);
     }
 }