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)); }
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); }
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)); }
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); }
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)); }
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)); }
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))); }
public EntityDtos <TEntityDto> FindByQuery(Query query) { LoggingFactory.LogInfo("Invoked FindAll for " + typeof(TEntity).Name); return(ExecuteCommand(locator => FindByQueryCommand(locator, query))); }
public EntityDtos <TEntityDto> FindAll() { LoggingFactory.LogInfo("Invoked FindAll for " + typeof(TEntity).Name); return(ExecuteCommand(FindAllCommand)); }
public CountryDto GetByCountryName(string countryName) { LoggingFactory.LogInfo("Invoked Country for User"); return(ExecuteCommand(locator => GetByCountrynameCommand(locator, countryName.Trim()))); }
public DtoResponse Delete(long id) { LoggingFactory.LogInfo("Invoked Delete for " + typeof(TEntity).Name + " : Id : " + id); return(ExecuteCommand(locator => DeleteCommand(locator, id))); }
public TEntityDto Create(TEntityDto entityDto, string userName) { LoggingFactory.LogInfo("Invoked Create for " + typeof(TEntity).Name); return(ExecuteCommand(locator => CreateNewCommand(locator, entityDto, userName))); }
/// <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))); }