Exemplo n.º 1
0
        public virtual TEntityDto UpdateCommand(IRepositoryLocator locator, TEntityDto entityDto, string userName)
        {
            string description = string.Empty;

            PopulateChildObjects = true;
            TEntity entityInstance = EntityDtoToEntity(entityDto);

            if (userName != null)
            {
                CheckForValidationsWhileUpdating(entityInstance);
                if ((AllowSaveWithWarnings && IsValidForBasicMandatoryFields) || IsValid)
                {
                    locator.GetRepository <TEntity>().Update(entityInstance);
                    description = "Updated " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entityInstance);
                    LoggActivity(description, userName);
                }
                else
                {
                    description = "Failed to create " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entityInstance);
                    LoggingFactory.LogInfo(description);
                }
            }
            else
            {
                locator.GetRepository <TEntity>().Update(entityInstance);
                description = "Failed to Login " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entityInstance);
                LoggingFactory.LogInfo(description);
                Container.RequestContext.Notifier.AddWarning(BusinessWarningEnum.Validation, "Invalid Username or Password");
            }
            //if(populateChildObjects!=null)
            //PopulateChildObjects = Convert.ToBoolean(populateChildObjects);
            PopulateChildObjects = false;
            return(EntityToEntityDto(entityInstance));
        }
Exemplo n.º 2
0
        public virtual TEntityDto CreateNewCommand(IRepositoryLocator locator, TEntityDto entityDto, string userName)
        {
            PopulateChildObjects = true;
            TEntity entity = EntityDtoToEntity(entityDto);

            //checks for the valid object and adds warnings/validation rules to Request object
            CheckForValidations(entity);

            TEntityDto result;

            if ((AllowSaveWithWarnings && IsValidForBasicMandatoryFields) || IsValid)
            {
                PopulateChildObjects = false;
                locator.GetRepository <TEntity>().Add(entity);
                LoggingFactory.LogInfo("Created " + typeof(TEntity).Name + " : Id : ");

                string description = "Created " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entity);
                LoggActivity(description, userName);
            }
            else
            {
                string description = "Failed to create " + typeof(TEntity).Name + " : " + GetEntityInstanceName(entity);
                LoggingFactory.LogInfo(description);
                //LoggActivity(description, loggedInUserDto);
            }
            //if (populateChildObjects != null)
            //    PopulateChildObjects = Convert.ToBoolean(populateChildObjects);
            PopulateChildObjects = false;
            result = EntityToEntityDto(entity);
            return(result);
        }
Exemplo n.º 3
0
        private ActivityLogDto CreateNewCommand(IRepositoryLocator locator, ActivityLogDto entityDto, string userName)
        {
            ActivityLog logInstance = Mapper.Map <ActivityLogDto, ActivityLog>(entityDto);

            locator.GetRepository <ActivityLog>().Add(logInstance);
            LoggingFactory.LogInfo("ActivityLog Created with ID :" + logInstance.LogId.ToString());
            return(Mapper.Map <ActivityLog, ActivityLogDto>(logInstance));
        }
Exemplo n.º 4
0
        public TEntityDto GetById(int id)
        {
            LoggingFactory.LogInfo("Invoked GetById for " + typeof(TEntity).Name + " : Id : " + id);
            var result = ExecuteCommand(loc => EntityToEntityDto(loc.GetById <TEntity>(id)));

            if (result == null)
            {
                Container.RequestContext.Notifier.AddWarning(BusinessWarningEnum.Default, typeof(TEntity).Name + " with id:" + id + " not found");
            }
            return(result);
        }
Exemplo n.º 5
0
        public override BankDto UpdateCommand(IRepositoryLocator locator, BankDto entityDto, string userName)
        {
            string description    = string.Empty;
            Bank   entityInstance = EntityDtoToEntity(entityDto);

            if (entityInstance.BankId == 0)
            {
                CheckForValidations(entityInstance);
            }
            else
            {
                CheckForValidationsWhileUpdating(entityInstance);
            }
            if ((AllowSaveWithWarnings && IsValidForBasicMandatoryFields) || IsValid)
            {
                if (entityInstance.BankId == 0)
                {
                    locator.GetRepository <Bank>().Add(entityInstance);
                    LoggingFactory.LogInfo("Created " + typeof(Bank).Name + " : Id : ");
                    description = "Created " + typeof(Bank).Name + " : " + GetEntityInstanceName(entityInstance);
                    LoggActivity(description, userName);
                }
                else
                {
                    locator.GetRepository <Bank>().Update(entityInstance);
                    description = "Updated " + typeof(Bank).Name + " : " + GetEntityInstanceName(entityInstance);
                    LoggActivity(description, userName);
                }
            }
            else
            {
                description = "Failed to create " + typeof(Bank).Name + " : " + GetEntityInstanceName(entityInstance);
                LoggingFactory.LogInfo(description);
                // This is not required as this call will overrite the existing Respose if it has warnings
                //var bankInstance = GetById(entityInstance.BankId);
                //entityInstance = AutoMapper.Mapper.Map<BankDto,Bank>(bankInstance);
            }
            return(EntityToEntityDto(entityInstance));
        }
Exemplo n.º 6
0
        public override CityVillageDto UpdateCommand(IRepositoryLocator locator, CityVillageDto entityDto, string userName)
        {
            string      description    = string.Empty;
            CityVillage entityInstance = EntityDtoToEntity(entityDto);

            if (entityInstance.CityVillageId == 0)
            {
                CheckForValidations(entityInstance);
            }
            else
            {
                CheckForValidationsWhileUpdating(entityInstance);
            }
            if ((AllowSaveWithWarnings && IsValidForBasicMandatoryFields) || IsValid)
            {
                if (entityInstance.CityVillageId == 0)
                {
                    locator.GetRepository <CityVillage>().Add(entityInstance);
                    LoggingFactory.LogInfo("Created " + typeof(CityVillage).Name + " : Id : ");
                    description = "Created " + typeof(CityVillage).Name + " : " + GetEntityInstanceName(entityInstance);
                    LoggActivity(description, userName);
                }
                else
                {
                    locator.GetRepository <CityVillage>().Update(entityInstance);
                    description = "Updated " + typeof(CityVillage).Name + " : " + GetEntityInstanceName(entityInstance);
                    LoggActivity(description, userName);
                }
            }
            else
            {
                description = "Failed to create " + typeof(CityVillage).Name + " : " + GetEntityInstanceName(entityInstance);
                LoggingFactory.LogInfo(description);
            }
            return(EntityToEntityDto(entityInstance));
        }
Exemplo n.º 7
0
 public EntityDtos <TEntityDto> FindBy(Query query, int pageIndex, int recordsPerPage)
 {
     LoggingFactory.LogInfo("Invoked FindAll for " + typeof(TEntity).Name);
     return(ExecuteCommand(locator => FindByCommand(locator, query, pageIndex, recordsPerPage)));
 }
Exemplo n.º 8
0
 public EntityDtos <TEntityDto> FindByQuery(Query query)
 {
     LoggingFactory.LogInfo("Invoked FindAll for " + typeof(TEntity).Name);
     return(ExecuteCommand(locator => FindByQueryCommand(locator, query)));
 }
Exemplo n.º 9
0
 public EntityDtos <TEntityDto> FindAll()
 {
     LoggingFactory.LogInfo("Invoked FindAll for " + typeof(TEntity).Name);
     return(ExecuteCommand(FindAllCommand));
 }
Exemplo n.º 10
0
 public CountryDto GetByCountryName(string countryName)
 {
     LoggingFactory.LogInfo("Invoked Country for User");
     return(ExecuteCommand(locator => GetByCountrynameCommand(locator, countryName.Trim())));
 }
Exemplo n.º 11
0
 public DtoResponse Delete(long id)
 {
     LoggingFactory.LogInfo("Invoked Delete for " + typeof(TEntity).Name + " : Id : " + id);
     return(ExecuteCommand(locator => DeleteCommand(locator, id)));
 }
Exemplo n.º 12
0
 public TEntityDto Create(TEntityDto entityDto, string userName)
 {
     LoggingFactory.LogInfo("Invoked Create for " + typeof(TEntity).Name);
     return(ExecuteCommand(locator => CreateNewCommand(locator, entityDto, userName)));
 }
Exemplo n.º 13
0
 /// <summary>
 /// This methods logs the activities of the user into ActivityLog Table.
 /// </summary>
 public ActivityLogDto Create(ActivityLogDto entityDto, string userName)
 {
     LoggingFactory.LogInfo("Invoked Create for ActivityLog");
     return(ExecuteCommand(locator => CreateNewCommand(locator, entityDto, userName)));
 }