/// <summary>
        /// Metoto encargado de grabar o actualizar un registro de la base de
        /// datos
        /// </summary>
        /// <param name="entityInsurancecompany"></param>
        /// <returns></returns>
        public CloudCatalogInsuranceCompanies SaveInsuranceCompay(CloudCatalogInsuranceCompanies entityInsurancecompany)
        {
            Boolean changeUpdateEntity = false;

            if (entityInsurancecompany != null)
            {
                using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
                {
                    CloudCatalogInsuranceCompanies entitieCurrent = Systimedb.CloudCatalogInsuranceCompanies.FirstOrDefault(I => I.IdInsuranceCompany == entityInsurancecompany.IdInsuranceCompany);
                    if (entitieCurrent == null)
                    {
                        entitieCurrent = Systimedb.CloudCatalogInsuranceCompanies.FirstOrDefault(I => I.IdCountry == entityInsurancecompany.IdCountry && I.TIN == entityInsurancecompany.TIN);
                    }


                    if (entitieCurrent != null)
                    {
                        entitieCurrent.Address = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Address, entityInsurancecompany.Address, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Email = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Email, entityInsurancecompany.Email, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.InsuranceCompany = UtilsDataAcces.ValidateDiferentString(entitieCurrent.InsuranceCompany, entityInsurancecompany.InsuranceCompany, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Mobile = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Mobile, entityInsurancecompany.Mobile, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Phone = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Phone, entityInsurancecompany.Phone, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Website = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Website, entityInsurancecompany.Website, false, changeUpdateEntity, out changeUpdateEntity);

                        if (changeUpdateEntity)
                        {
                            entitieCurrent.UpdatedAt = DateTime.Now;
                            Systimedb.SaveChanges();
                        }

                        return(entitieCurrent);
                    }
                    else
                    {
                        entityInsurancecompany.CreatedAt = DateTime.Now;
                        Systimedb.CloudCatalogInsuranceCompanies.Add(entityInsurancecompany);
                        if (Systimedb.SaveChanges() > 0)
                        {
                            return(entityInsurancecompany);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// MEtoto encargado de guardar el dealer shop o actualizar en la base
        /// de datos de systime
        /// </summary>
        /// <param name="entityDealerShop"></param>
        /// <returns></returns>
        public CloudCatalogDealerShops SaveDealerShop(CloudCatalogDealerShops entityDealerShop)
        {
            Boolean changeUpdateEntity = false;

            if (entityDealerShop != null)
            {
                using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
                {
                    CloudCatalogDealerShops entitieCurrent = Systimedb.CloudCatalogDealerShops.FirstOrDefault(I => I.IdDealerShop == entityDealerShop.IdDealerShop);
                    if (entitieCurrent != null)
                    {
                        entitieCurrent.Address = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Address, entityDealerShop.Address, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Email = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Email, entityDealerShop.Email, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdCity = (UtilsDataAcces.ValidateDiferentInt(entitieCurrent.IdCity, entityDealerShop.IdCity, false, changeUpdateEntity, out changeUpdateEntity)).Value;

                        entitieCurrent.Latitude = (UtilsDataAcces.ValidateDiferentDouble(entitieCurrent.Latitude, entityDealerShop.Latitude, false, changeUpdateEntity, out changeUpdateEntity)) ?? 0;

                        entitieCurrent.Longitude = (UtilsDataAcces.ValidateDiferentDouble(entitieCurrent.Longitude, entityDealerShop.Longitude, false, changeUpdateEntity, out changeUpdateEntity)) ?? 0;

                        entitieCurrent.Mobile = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Mobile, entityDealerShop.Mobile, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Phone = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Phone, entityDealerShop.Phone, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Shop = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Shop, entityDealerShop.Shop, true, changeUpdateEntity, out changeUpdateEntity);

                        if (changeUpdateEntity)
                        {
                            entitieCurrent.UpdatedAt = DateTime.Now;
                            Systimedb.SaveChanges();
                        }

                        return(entitieCurrent);
                    }
                    else
                    {
                        entityDealerShop.CreatedAt = DateTime.Now;
                        Systimedb.CloudCatalogDealerShops.Add(entityDealerShop);
                        if (Systimedb.SaveChanges() > 0)
                        {
                            return(entityDealerShop);
                        }
                    }
                }
            }
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Metoto encargado de guarrar un trabajador en systime
        /// considerando el cargo al que pertenece
        /// </summary>
        /// <param name="entityWorker"></param>
        /// <returns></returns>
        public Workers SaveWorker(Workers entityWorker, String userModify)
        {
            if (entityWorker != null)
            {
                ////Guarda el job title y obtiene el id
                //if (entityWorker.IdJobTitle == ConstantsSystimeDataAccess.ID_JOB_TITLE_DEFAULT)
                //    entityWorker.IdJobTitle = ConstantsSystimeDataAccess.ID_JOB_TITLE_DEFAULT;

                using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
                {
                    Workers entitieCurrent = Systimedb.Workers.FirstOrDefault(I => I.IdWorker == entityWorker.IdWorker);

                    if (entitieCurrent != null)
                    {
                        return(entitieCurrent);
                    }
                    else
                    {
                        entityWorker.CreatedAt   = DateTime.Now;
                        entityWorker.CreatedById = userModify;
                        Systimedb.Workers.Add(entityWorker);

                        if (Systimedb.SaveChanges() > 0)
                        {
                            return(entityWorker);
                        }
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// Metoto encargado de guardar o actualizar un error de carga de ordenes de trabajo
        /// </summary>
        /// <param name="workOrderErrorEntity"></param>
        /// <param name="userModify"></param>
        /// <returns></returns>
        public Boolean SaveWorkOrderError(WorkOrderLoadErrorLog workOrderErrorEntity, String userModify)
        {
            if (workOrderErrorEntity != null)
            {
                Boolean isUpdate = false;
                using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
                {
                    WorkOrderLoadErrorLog currentEntity = Systimedb.WorkOrderLoadErrorLog.FirstOrDefault(w => w.IdWorkOrderNumberErp == workOrderErrorEntity.IdWorkOrderNumberErp && w.idDealerShopOtErp == workOrderErrorEntity.idDealerShopOtErp);
                    if (currentEntity != null)
                    {
                        //Update
                        currentEntity.idCustomerOT     = UtilsDataAcces.ValidateDiferentString(currentEntity.idCustomerOT, workOrderErrorEntity.idCustomerOT, true, isUpdate, out isUpdate);
                        currentEntity.idVehicle        = UtilsDataAcces.ValidateDiferentString(currentEntity.idVehicle, workOrderErrorEntity.idVehicle, false, isUpdate, out isUpdate);
                        currentEntity.idWorkerOT       = UtilsDataAcces.ValidateDiferentString(currentEntity.idWorkerOT, workOrderErrorEntity.idWorkerOT, true, isUpdate, out isUpdate);
                        currentEntity.idWorkerOT       = UtilsDataAcces.ValidateDiferentString(currentEntity.idWorkerOT, workOrderErrorEntity.idWorkerOT, true, isUpdate, out isUpdate);
                        currentEntity.CloudUpdateError = UtilsDataAcces.ValidateDiferentString(currentEntity.CloudUpdateError, workOrderErrorEntity.CloudUpdateError, true, isUpdate, out isUpdate);

                        if (isUpdate)
                        {
                            currentEntity.UpdatedAt   = DateTime.Now;
                            currentEntity.UpdatedById = userModify;
                            Systimedb.SaveChanges();
                        }
                        return(true);
                    }
                    else
                    {
                        //Insert
                        workOrderErrorEntity.CreatedAt   = DateTime.Now;
                        workOrderErrorEntity.CreatedById = userModify;
                        Systimedb.WorkOrderLoadErrorLog.Add(workOrderErrorEntity);
                        if (Systimedb.SaveChanges() > 0)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #5
0
 /// <summary>
 /// Metoto encargado de actualizar si un vehiculo tiene o no fotografia
 /// </summary>
 /// <param name="idVinVehilce">id del vehiculo</param>
 /// <param name="hasPhoto">si tiene fotografia o no</param>
 /// <returns></returns>
 public Boolean UpdateHasPhoto(String idVinVehilce, Boolean hasPhoto)
 {
     if (!String.IsNullOrEmpty(idVinVehilce))
     {
         using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
         {
             Vehicles vehicles = Systimedb.Vehicles.FirstOrDefault(v => v.IdVinNumber == idVinVehilce);
             if (vehicles != null)
             {
                 vehicles.HasPhoto = hasPhoto;
                 if (Systimedb.SaveChanges() > 0)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 /// <summary>
 /// Metodo encargado de eliminar un error de cargar de orden de trabajo
 /// </summary>
 /// <param name="idWorkOrder"></param>
 /// <returns></returns>
 public Boolean DeleteWorkOrderError(String idWorkOrderErp, String iddealerShopErp)
 {
     if (!String.IsNullOrEmpty(idWorkOrderErp) && !String.IsNullOrEmpty(iddealerShopErp))
     {
         using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
         {
             WorkOrderLoadErrorLog currentEntity = Systimedb.WorkOrderLoadErrorLog.FirstOrDefault(w => w.IdWorkOrderNumberErp == idWorkOrderErp && w.idDealerShopOtErp == iddealerShopErp);
             if (currentEntity != null)
             {
                 Systimedb.WorkOrderLoadErrorLog.Remove(currentEntity);
                 if (Systimedb.SaveChanges() > 0)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Beispiel #7
0
        /// <summary>
        /// Metoto encargado de guardar o actualizar un vehiculo
        /// en la base de datos de systime
        /// </summary>
        /// <param name="entityVehicle"></param>
        /// <param name="userModify"></param>
        /// <returns></returns>
        public Vehicles SaveVehicle(Vehicles entityVehicle, String userModify)
        {
            Vehicles currentVehicle     = null;
            Boolean  changeUpdateEntity = false;

            if (entityVehicle != null)
            {
                using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
                {
                    List <Vehicles> entitiesCurrentVehicles = Systimedb.Vehicles.Where(v => v.Plate == entityVehicle.Plate).ToList();
                    if (entitiesCurrentVehicles == null || entitiesCurrentVehicles.Count == 0)
                    {
                        entitiesCurrentVehicles = Systimedb.Vehicles.Where(v => v.IdVinNumber == entityVehicle.IdVinNumber).ToList();
                    }
                    if (entitiesCurrentVehicles.Count > 0)
                    {
                        if (entitiesCurrentVehicles.Count == 1)
                        {
                            currentVehicle = entitiesCurrentVehicles[0];
                        }
                        else if (entitiesCurrentVehicles.Count > 1)
                        {
                            currentVehicle = entitiesCurrentVehicles.FirstOrDefault(v => v.IdCity == entityVehicle.IdCity);
                        }

                        if (currentVehicle != null)
                        {
                            //Comienza el proceso de actualizacion

                            //Entity framwwork comienza a hacer seguimiento a la entidad
                            Systimedb.Vehicles.Attach(currentVehicle);
                            //Cambia el etado a modificado
                            currentVehicle.Color = UtilsDataAcces.ValidateDiferentString(currentVehicle.Color, entityVehicle.Color, false, changeUpdateEntity, out changeUpdateEntity);

                            currentVehicle.DealerVehicleModel = UtilsDataAcces.ValidateDiferentString(currentVehicle.DealerVehicleModel, entityVehicle.DealerVehicleModel, true, changeUpdateEntity, out changeUpdateEntity);

                            currentVehicle.IdCity = (UtilsDataAcces.ValidateDiferentInt(currentVehicle.IdCity, entityVehicle.IdCity, false, changeUpdateEntity, out changeUpdateEntity)) ?? 0;

                            currentVehicle.IdInsuranceCompany = UtilsDataAcces.ValidateDiferentInt(currentVehicle.IdInsuranceCompany, entityVehicle.IdInsuranceCompany, true, changeUpdateEntity, out changeUpdateEntity);

                            currentVehicle.IdVehicleModel = (UtilsDataAcces.ValidateDiferentInt(currentVehicle.IdVehicleModel, entityVehicle.IdVehicleModel, false, changeUpdateEntity, out changeUpdateEntity)) ?? 0;

                            currentVehicle.IdVehicleServiceType = (UtilsDataAcces.ValidateDiferentInt(currentVehicle.IdVehicleServiceType, entityVehicle.IdVehicleServiceType, false, changeUpdateEntity, out changeUpdateEntity));

                            currentVehicle.IdVehicleType = (UtilsDataAcces.ValidateDiferentInt(currentVehicle.IdVehicleType, entityVehicle.IdVehicleType, false, changeUpdateEntity, out changeUpdateEntity));

                            if (currentVehicle.LastMileage != entityVehicle.LastMileage && entityVehicle.LastMileage != null && currentVehicle.LastMileage < entityVehicle.LastMileage)
                            {
                                currentVehicle.LastMileage = entityVehicle.LastMileage;
                                changeUpdateEntity         = true;
                            }

                            currentVehicle.ModelYear = (UtilsDataAcces.ValidateDiferentInt(currentVehicle.ModelYear, entityVehicle.ModelYear, false, changeUpdateEntity, out changeUpdateEntity)).Value;

                            currentVehicle.Plate = UtilsDataAcces.ValidateDiferentString(currentVehicle.Plate, entityVehicle.Plate, false, changeUpdateEntity, out changeUpdateEntity);

                            currentVehicle.DealerCity = UtilsDataAcces.ValidateDiferentString(currentVehicle.DealerCity, entityVehicle.DealerCity, true, changeUpdateEntity, out changeUpdateEntity);

                            currentVehicle.IdCustomerOwner = (UtilsDataAcces.ValidateDiferentDecimal(currentVehicle.IdCustomerOwner, entityVehicle.IdCustomerOwner, true, changeUpdateEntity, out changeUpdateEntity)).Value;

                            currentVehicle.SaleGuaranteeAt = UtilsDataAcces.ValidateDiferentDateTime(currentVehicle.SaleGuaranteeAt, entityVehicle.SaleGuaranteeAt, changeUpdateEntity, out changeUpdateEntity);

                            currentVehicle.GuaranteedSaleDistanceTraveled = UtilsDataAcces.ValidateDiferentInt(currentVehicle.GuaranteedSaleDistanceTraveled, entityVehicle.GuaranteedSaleDistanceTraveled, false, changeUpdateEntity, out changeUpdateEntity);

                            if (changeUpdateEntity)
                            {
                                currentVehicle.UpdatedAt              = DateTime.Now;
                                currentVehicle.UpdatedById            = userModify;
                                Systimedb.Entry(currentVehicle).State = EntityState.Modified;
                                Systimedb.SaveChanges();
                            }
                            return(currentVehicle);
                        }
                    }
                    else
                    {
                        entityVehicle.CreatedAt   = DateTime.Now;
                        entityVehicle.CreatedById = userModify;
                        Systimedb.Vehicles.Add(entityVehicle);
                        if (Systimedb.SaveChanges() > 0)
                        {
                            return(entityVehicle);
                        }
                    }
                }
            }
            return(null);
        }
Beispiel #8
0
        /// <summary>
        /// Metoto encargado de grabar o actualizar un entitdad de tipo Customer
        /// en la base de datos de systime
        /// </summary>
        /// <param name="entityCustomers">entidad customer</param>
        /// <returns>id en la base de datos asignado a customer</returns>
        public Customers SaveCustomer(Customers entityCustomers, String userModify)
        {
            Boolean changeUpdateEntity = false;

            if (entityCustomers != null)
            {
                using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
                {
                    List <Customers> entitiesCurrent = Systimedb.Customers.Where(c => c.DocumentNumber == entityCustomers.DocumentNumber && c.IdCountry == entityCustomers.IdCountry).ToList();
                    Customers        entitieCurrent  = null;
                    if (entitiesCurrent.Count > 0)
                    {
                        if (entitiesCurrent.Count == 1)
                        {
                            entitieCurrent = entitiesCurrent[0];
                        }
                        else if (entitiesCurrent.Count > 1)
                        {
                            entitieCurrent = entitiesCurrent.FirstOrDefault(c => c.IdCountry == entityCustomers.IdCountry);
                        }

                        if (entitieCurrent != null)
                        {
                            //Entity framwwork comienza a hacer seguimiento a la entidad
                            Systimedb.Customers.Attach(entitieCurrent);
                            //Cambia el etado a modificado

                            entitieCurrent.IdCountry = UtilsDataAcces.ValidateDiferentString(entitieCurrent.IdCountry, entityCustomers.IdCountry, true, changeUpdateEntity, out changeUpdateEntity);

                            entitieCurrent.IdCity = (UtilsDataAcces.ValidateDiferentInt(entitieCurrent.IdCity, entityCustomers.IdCity, false, changeUpdateEntity, out changeUpdateEntity)).Value;

                            entitieCurrent.Email = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Email, entityCustomers.Email, false, changeUpdateEntity, out changeUpdateEntity);

                            entitieCurrent.FullName = UtilsDataAcces.ValidateDiferentString(entitieCurrent.FullName, entityCustomers.FullName, false, changeUpdateEntity, out changeUpdateEntity);

                            entitieCurrent.DocumentNumber = UtilsDataAcces.ValidateDiferentString(entitieCurrent.DocumentNumber, entityCustomers.DocumentNumber, false, changeUpdateEntity, out changeUpdateEntity);

                            entitieCurrent.Mobile = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Mobile, entityCustomers.Mobile, false, changeUpdateEntity, out changeUpdateEntity);

                            entitieCurrent.Phone = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Phone, entityCustomers.Phone, false, changeUpdateEntity, out changeUpdateEntity);


                            if (changeUpdateEntity)
                            {
                                Systimedb.Entry(entitieCurrent).State = EntityState.Modified;
                                entitieCurrent.UpdatedAt = DateTime.Now;
                                Systimedb.SaveChanges();
                            }
                            return(entitieCurrent);
                        }
                    }
                    else
                    {
                        entityCustomers.CreatedById = userModify;
                        entityCustomers.CreatedAt   = DateTime.Now;
                        Systimedb.Customers.Add(entityCustomers);

                        if (Systimedb.SaveChanges() > 0)
                        {
                            return(entityCustomers);
                        }
                    }
                }
            }
            return(null);
        }
Beispiel #9
0
        /// <summary>
        /// Metoo encargado de grabar y actualizar una orden de trabajo en systime
        /// </summary>
        /// <param name="entityWorkOrder"></param>
        /// <param name="userModify"></param>
        /// <returns></returns>
        public WorkOrders SaveWorkOrder(WorkOrders entityWorkOrder, String userModify)
        {
            Boolean changeUpdateEntity = false;

            if (entityWorkOrder != null)
            {
                using (SystimedbEntities Systimedb = new SystimedbEntities(ConectionString))
                {
                    WorkOrders entitieCurrent = Systimedb.WorkOrders.FirstOrDefault(w => w.WorkOrderNumber == entityWorkOrder.WorkOrderNumber && w.IdDealerShop == entityWorkOrder.IdDealerShop);
                    if (entitieCurrent != null)
                    {
                        entitieCurrent.AuthorizedAt = UtilsDataAcces.ValidateDiferentDateTime(entitieCurrent.AuthorizedAt, entityWorkOrder.AuthorizedAt, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.FeedBack = UtilsDataAcces.ValidateDiferentString(entitieCurrent.FeedBack, entityWorkOrder.FeedBack, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.HasTotalLoss = UtilsDataAcces.ValidateDiferentBoolean(entitieCurrent.HasTotalLoss, entityWorkOrder.HasTotalLoss, changeUpdateEntity, out changeUpdateEntity) ?? false;

                        entitieCurrent.IdCurrentOperation = UtilsDataAcces.ValidateDiferentInt(entitieCurrent.IdCurrentOperation, entityWorkOrder.IdCurrentOperation, true, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdCurrentWorker = UtilsDataAcces.ValidateDiferentString(entitieCurrent.IdCurrentWorker, entityWorkOrder.IdCurrentWorker, true, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdCustomer = (UtilsDataAcces.ValidateDiferentDecimal(entitieCurrent.IdCustomer, entityWorkOrder.IdCustomer, true, changeUpdateEntity, out changeUpdateEntity)).Value;

                        entitieCurrent.IdDealerShop = UtilsDataAcces.ValidateDiferentString(entitieCurrent.IdDealerShop, entityWorkOrder.IdDealerShop, true, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdErpQuote = UtilsDataAcces.ValidateDiferentInt(entitieCurrent.IdErpQuote, entityWorkOrder.IdErpQuote, true, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdInsuranceCompany = UtilsDataAcces.ValidateDiferentInt(entitieCurrent.IdInsuranceCompany, entityWorkOrder.IdInsuranceCompany, true, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdPhysicalTag = UtilsDataAcces.ValidateDiferentInt(entitieCurrent.IdPhysicalTag, entityWorkOrder.IdPhysicalTag, true, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdSalesRepresentative = UtilsDataAcces.ValidateDiferentString(entitieCurrent.IdSalesRepresentative, entityWorkOrder.IdSalesRepresentative, true, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IdVinNumber = UtilsDataAcces.ValidateDiferentString(entitieCurrent.IdVinNumber, entityWorkOrder.IdVinNumber, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.InvoicedAt = UtilsDataAcces.ValidateDiferentDateTime(entitieCurrent.InvoicedAt, entityWorkOrder.InvoicedAt, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Note = UtilsDataAcces.ValidateDiferentString(entitieCurrent.Note, entityWorkOrder.Note, false, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.OpenOtAt = UtilsDataAcces.ValidateDiferentDateTime(entitieCurrent.OpenOtAt, entityWorkOrder.OpenOtAt, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.PartsCompletedAt = UtilsDataAcces.ValidateDiferentDateTime(entitieCurrent.PartsCompletedAt, entityWorkOrder.PartsCompletedAt, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.PickedUpAt = UtilsDataAcces.ValidateDiferentDateTime(entitieCurrent.PickedUpAt, entityWorkOrder.PickedUpAt, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.IsInvoiced = UtilsDataAcces.ValidateDiferentBoolean(entitieCurrent.IsInvoiced, entityWorkOrder.IsInvoiced, changeUpdateEntity, out changeUpdateEntity) ?? false;


                        entitieCurrent.PromisedAt = UtilsDataAcces.ValidateDiferentDateTime(entitieCurrent.PromisedAt, entityWorkOrder.PromisedAt, changeUpdateEntity, out changeUpdateEntity);

                        entitieCurrent.Canceled = UtilsDataAcces.ValidateDiferentBoolean(entitieCurrent.Canceled, entityWorkOrder.Canceled, changeUpdateEntity, out changeUpdateEntity);



                        if (changeUpdateEntity)
                        {
                            entitieCurrent.UpdatedAt   = DateTime.Now;
                            entitieCurrent.UpdatedById = userModify;
                            Systimedb.SaveChanges();
                        }

                        return(entitieCurrent);
                    }
                    else
                    {
                        entityWorkOrder.CreatedAt   = DateTime.Now;
                        entityWorkOrder.CreatedById = userModify;
                        Systimedb.WorkOrders.Add(entityWorkOrder);
                        if (Systimedb.SaveChanges() > 0)
                        {
                            return(entityWorkOrder);
                        }
                    }
                }
            }
            return(null);
        }