Exemple #1
0
        public Common.OperationResult Add(Common.DataContract.EntityDataContract dataContract)
        {
            var handler = DataAccess.Core.GetFactory().GetInstance <IEntityHandler>();

            dataContract.CreatedBy = Common.SessionData.ResourceId;
            dataContract.CreatedOn = DateTime.Now;

            var val = dataContract.Validate();

            if (!val.IsValid)
            {
                return(new Common.OperationResult(val));
            }

            var result = handler.Add(dataContract);

            if (result.Status == Common.OperationResultStatus.Succesfull)
            {
                UpdateEntityStatus(dataContract);
                UpdateEntityFields(dataContract);

                if (dataContract.EntityType.Equals("T"))
                {
                    SetTrigger(dataContract.SQLTableName, dataContract.Id, dataContract.StatusField, dataContract.UserDefinedCodeField, dataContract.EntityFields);
                }
            }

            return(result);
        }
Exemple #2
0
        public Common.OperationResult Delete(Common.DataContract.EntityDataContract dataContract)
        {
            var handler       = DataAccess.Core.GetFactory().GetInstance <IEntityHandler>();
            var fieldsHandler = DataAccess.Core.GetFactory().GetInstance <IEntityFieldHandler>();
            var statusHandler = DataAccess.Core.GetFactory().GetInstance <IEntityStatusHandler>();

            fieldsHandler.DeleteAll(dataContract.Id);
            statusHandler.DeleteAll(dataContract.Id);


            return(handler.Delete(dataContract));
        }
Exemple #3
0
        public override Common.OperationResult Add(Common.DataContract.EntityDataContract dataContract)
        {
            if (dataContract == null)
            {
                throw new ArgumentException("Cannot be Null", "dataContract");
            }

            try
            {
                Core.MainDataContextInstance().SGW_Entities.InsertOnSubmit(GetLinqObj(dataContract));
                Core.MainDataContextInstance().SubmitChanges();
                return(new Common.OperationResult());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override SGW_Entity GetLinqObj(Common.DataContract.EntityDataContract dataContract, SGW_Entity linq)
        {
            if (dataContract == null)
            {
                return(null);
            }

            linq.Name            = dataContract.Description;
            linq.EntityId        = dataContract.Id;
            linq.StatusFieldName = dataContract.StatusField;
            linq.SQLTableName    = dataContract.SQLTableName;
            linq.EntityType      = dataContract.EntityType;
            linq.CreatedOn       = dataContract.CreatedOn;
            linq.CreatedBy       = dataContract.CreatedBy;
            linq.UpdatedOn       = dataContract.UpdatedOn;
            linq.UpdatedBy       = dataContract.UpdatedBy;
            return(linq);
        }
        public override Common.DataContract.EntityDataContract GetDataContract(SGW_Entity linqObj)
        {
            if (linqObj == null)
            {
                return(null);
            }

            Common.DataContract.EntityDataContract dataContract = new Common.DataContract.EntityDataContract();
            dataContract.Id           = linqObj.EntityId;
            dataContract.Description  = linqObj.Name;
            dataContract.EntityType   = linqObj.EntityType;
            dataContract.StatusField  = linqObj.StatusFieldName;
            dataContract.SQLTableName = linqObj.SQLTableName;
            dataContract.CreatedBy    = linqObj.CreatedBy;
            dataContract.CreatedOn    = linqObj.CreatedOn;
            dataContract.UpdatedBy    = linqObj.UpdatedBy;
            dataContract.UpdatedOn    = linqObj.UpdatedOn;
            return(dataContract);
        }
Exemple #6
0
        public Common.OperationResult Add(Common.DataContract.EntityDataContract dataContract)
        {
            var handler = DataAccess.Core.GetFactory().GetInstance <IEntityHandler>();

            dataContract.CreatedBy = Common.SessionData.ResourceId;
            dataContract.CreatedOn = DateTime.Now;

            var val = dataContract.Validate();

            if (!val.IsValid)
            {
                return(new Common.OperationResult(val));
            }

            var result = handler.Add(dataContract);

            if (result.Status == Common.OperationResultStatus.Succesfull)
            {
                UpdateEntityStatus(dataContract);
                UpdateEntityFields(dataContract);
            }

            return(result);
        }
Exemple #7
0
        public override Common.OperationResult Delete(Common.DataContract.EntityDataContract dataContract)
        {
            if (dataContract == null)
            {
                throw new ArgumentException("Cannot be Null", "dataContract");
            }

            try
            {
                SGW_Entity obj = Core.MainDataContextInstance().SGW_Entities.Where(o => o.EntityId.Equals(dataContract.Id)).FirstOrDefault();
                if (obj == null)
                {
                    return(new Common.OperationResult(Common.OperationResultStatus.ValidationFailure, "Entidade não encontrada."));
                }

                Core.MainDataContextInstance().SGW_Entities.DeleteOnSubmit(obj);
                Core.MainDataContextInstance().SubmitChanges();
                return(new Common.OperationResult());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #8
0
        public Common.OperationResult Delete(Common.DataContract.EntityDataContract dataContract)
        {
            var handler = DataAccess.Core.GetFactory().GetInstance <IEntityHandler>();

            return(handler.Delete(dataContract));
        }
Exemple #9
0
 public override SGW_Entity GetLinqObj(Common.DataContract.EntityDataContract dataContract)
 {
     return(GetLinqObj(dataContract, new SGW_Entity()));
 }