public bool Add(ICommonEntity _project) { var project = (_project as ProjectEntity); string str = string.Empty; try { str = string.Format(@"insert into tblproject (ProjectCode, ProjectName, StartedDate, EndDate, ScopeMM, CustomerName,Status) values ('{0}','{1}','{2}','{3}',{4},'{5}',{6}) ", project.ProjectCode, project.ProjectName, project.StartedDate.ToString("yyyy-MM-dd"), project.EndDate.ToString("yyyy-MM-dd"), project.ScopeMM, project.CustomerName, (int)project.Status ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public bool Edit(ICommonEntity _employee, int ID) { var employee = (_employee as EmployeeEntity); string str = string.Empty; try { str = string.Format(@"update tblEmployee set EmployeeNumber = '{0}',EmployeeFirstName= '{1}',EmployeeLastName ='{2}',Address = '{3}',IDCard = '{4}',DOB = '{5}',JobRankType={6},JobRankLevel={7},SalaryLevel={8}, SalarySubLevel={9} where ID = {10}", employee.EmployeeNumber, employee.EmployeeFirstName, employee.EmployeeLastName, employee.Address, employee.IDCard, employee.DOB.ToString("yyyy-MM-dd"), (int)employee.JobRankType, (int)employee.JobRankLevel, (int)employee.SalaryLevel, employee.SalarySubLevel, ID ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public bool Add(ICommonEntity _employee) { var employee = (_employee as EmployeeEntity); try { var str = string.Format(@"insert into tblEmployee (EmployeeNumber,EmployeeFirstName, EmployeeLastName,Address,IDCard,DOB,Sex,JobRankType,JobRankLevel, SalaryLevel, SalarySubLevel) values ('{0}','{1}','{2}','{3}','{4}','{5}',{6},{7},{8},{9},{10})", employee.EmployeeNumber, employee.EmployeeFirstName, employee.EmployeeLastName, employee.Address, employee.IDCard, employee.DOB.ToString("yyyy-MM-dd"), (int)employee.Sex, (int)employee.JobRankType, (int)employee.JobRankLevel, (int)employee.SalaryLevel, employee.SalarySubLevel ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public bool Add(ICommonEntity _task) { var task = (_task as TaskEntity); string str = string.Empty; try { str = string.Format(@"insert into tblTask (TaskCode,TaskName,Description,Assignee,Reporter,Status,Priority,TaskType,ProjectID) values ('{0}','{1}','{2}',{3},{4},{5},{6},{7},{8}) ", task.TaskCode, task.TaskName, task.Description, task.Assignee.ID, task.Reporter.ID, (int)task.Status, (int)task.Priority, (int)task.TaskType, task.Project.ID ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public bool Edit(ICommonEntity _task, int ID) { var task = (_task as TaskEntity); string str = string.Empty; try { str = string.Format(@"update tblTask set TaskCode = '{0}',TaskName= '{1}',Description ='{2}',Assignee = {3},Reporter = {4},Status = {5},Priority={6},TaskType={7} where ID = {8}", task.TaskCode, task.TaskName, task.Description, task.Assignee.ID, task.Reporter.ID, (int)task.Status, (int)task.Priority, (int)task.TaskType, ID ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public bool Edit(ICommonEntity _project, int ID) { var project = (_project as ProjectEntity); string str = string.Empty; try { str = string.Format(@"update tblproject set ProjectCode = '{0}',ProjectName= '{1}',StartedDate ='{2}',EndDate = '{3}',ScopeMM = {4},CustomerName = '{5}',Status={6} where ID = {7}", project.ProjectCode, project.ProjectName, project.StartedDate.ToString("yyyy-MM-dd"), project.EndDate.ToString("yyyy-MM-dd"), project.ScopeMM, project.CustomerName, (int)project.Status, ID ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public bool Edit(ICommonEntity _projectEmployee, int ID) { var projectEmployee = (_projectEmployee as ProjectEmployeeEntity); string str = string.Empty; try { str = string.Format(@"update project_employee set ProjectID = {0},EmployeeID= {1},StartedDate ='{2}',EndDate = '{3}',Role = {4},Active = {5} where ID = {6}", projectEmployee.Project.ID, projectEmployee.Employee.ID, projectEmployee.StartedDate.ToString("yyyy-MM-dd"), projectEmployee.EndDate.ToString("yyyy-MM-dd"), (int)projectEmployee.Role, (int)projectEmployee.Active, ID ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public static void SetCreateData(this ICommonEntity entity) { if (entity != null) { entity.CreateDate = DateTime.UtcNow.ToLocalTime(); if (Context.CurrentUser != null) { entity.CreatedBy = Context.CurrentUser.Name; } } }
public bool GetIsExist(ICommonEntity model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (model.ID == 0) { return(false); } string sql = "SELECT 1 FROM [{0}] WHERE [ID]=@p0".FormatWith(model.GetType().Name); return(!_db.ExecuteScalar(new SqlCommand(sql), new SqlParameter("@p0", model.ID)).IsNullOrDbNull()); }
public static void CopyGenericPropertiesFrom(this ICommonEntity storage, ICommonEntity source) { if (storage is null) { throw new NullReferenceException(); } if (source is null) { throw new ArgumentNullException(nameof(source), "Source should not be null"); } storage.EntityCreatedDate = source.EntityCreatedDate; storage.EntityUpdatedDate = source.EntityUpdatedDate; storage.EntityDeletedDate = source.EntityDeletedDate; storage.IsDeleted = source.IsDeleted; }
public bool Add(ICommonEntity _jobKpiAssessment) { var jobKpiAssessment = (_jobKpiAssessment as JobKpiEntity); string str = string.Empty; try { str = string.Format(@"insert into tblJobKpiAssessment (EmployeeID, CreatedDate, RoleInAssessment, Status) values ({0},'{1}',{2},{3}) ", jobKpiAssessment.Employee.ID, jobKpiAssessment.CreatedDate.ToString("yyyy-MM-dd"), (int)jobKpiAssessment.RoleInAssessment, (int)jobKpiAssessment.Status ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
private async Task <ICommonEntity> CalculateBalanceAndAnualBalanceResults(ICommonEntity entity) { var balance = await _balanceRepository.GetByIdAsync(entity.BalanceId); if (balance == null) { return(null); } await _balanceRepository.CalculateResult(balance); var anualBalance = await _anualBalanceRepository.GetByIdAsync(balance.AnualBalanceId); if (anualBalance == null) { return(null); } await _anualBalanceRepository.CalculateResult(anualBalance); return(entity); }
public bool Edit(ICommonEntity _jobKpiAssessment, int ID) { var jobKpiAssessment = (_jobKpiAssessment as JobKpiEntity); string str = string.Empty; try { str = string.Format(@"update tblJobKpiAssessment set EmployeeID = {0},CreatedDate= '{1}',RoleInAssessment ={2},Status = {3} where ID = {4}", jobKpiAssessment.Employee.ID, jobKpiAssessment.CreatedDate.ToString("yyyy-MM-dd"), (int)jobKpiAssessment.RoleInAssessment, (int)jobKpiAssessment.Status, ID ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public bool Add(ICommonEntity _projectEmployee) { var projectEmployee = (_projectEmployee as ProjectEmployeeEntity); string str = string.Empty; try { str = string.Format(@"insert into project_employee (ProjectID, EmployeeID, StartedDate, EndDate, Role, Active) values ({0},{1},'{2}','{3}',{4},{5}) ", projectEmployee.Project.ID, projectEmployee.Employee.ID, projectEmployee.StartedDate.ToString("yyyy-MM-dd"), projectEmployee.EndDate.ToString("yyyy-MM-dd"), (int)projectEmployee.Role, (int)projectEmployee.Active ); DBManager.InstantDBManger.QueryExecutionWithTransaction(str); return(true); } catch (Exception exp) { CommonFunctions.ShowErrorDialog("SQL error:" + exp.ToString()); return(false); } }
public ICommonDto GetModel <TDto>(ICommonEntity domainEntity) where TDto : CommonDto { if (TypesEqual <TDto, ClientDto>()) { var client = (Domain.Entity.Client)domainEntity; return(new ClientDto { Id = client.Id, UserId = client.UserId, Active = client.Active, AllowedOrigin = client.AllowedOrigin, ApplicationType = GetApplicationTypeString(client.ApplicationType), RefreshTokenLifeTime = client.RefreshTokenLifeTime, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("GetClient", new { id = client.Id }), Method = "GET" }, new Link { Rel = "Get user", Href = Url.Link("GetUser", new { id = client.UserId }), Method = "GET" }, new Link { Rel = "Update client", Href = Url.Link("UpdateClient", new { id = client.Id }), Method = "PUT" } } }); } if (TypesEqual <TDto, MyClientDto>()) { var client = (Domain.Entity.Client)domainEntity; return(new MyClientDto { Id = client.Id, UserId = client.UserId, Active = client.Active, AllowedOrigin = client.AllowedOrigin, ApplicationType = GetApplicationTypeString(client.ApplicationType), RefreshTokenLifeTime = client.RefreshTokenLifeTime, Links = new List <Link> { new Link { Rel = "My account", Href = Url.Link("MyAccount", null), Method = "GET" }, new Link { Rel = "Add new client", Href = Url.Link("UserCreateClient", null), Method = "POST" }, new Link { Rel = "Self", Href = Url.Link("MyClient", new { id = client.Id }), Method = "GET" }, new Link { Rel = "Generate new client secret", Href = Url.Link("UserGenerateNewClientSecret", new { id = client.Id }), Method = "GET" }, new Link { Rel = "Change client origin", Href = Url.Link("ChangeClientOrigin", new { id = client.Id }), Method = "POST" }, new Link { Rel = "Delete client", Href = Url.Link("DeleteMyClient", new { id = client.Id }), Method = "DELETE" } } }); } if (TypesEqual <TDto, BaseClientDto>()) { var client = (Domain.Entity.Client)domainEntity; return(new BaseClientDto { Id = client.Id, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("MyClient", new { id = client.Id }), Method = "GET" }, new Link { Rel = "Add new client", Href = Url.Link("UserCreateClient", null), Method = "POST" }, new Link { Rel = "Generate new client secret", Href = Url.Link("UserGenerateNewClientSecret", new { id = client.Id }), Method = "GET" }, new Link { Rel = "Change client origin", Href = Url.Link("ChangeClientOrigin", new { id = client.Id }), Method = "POST" }, new Link { Rel = "Delete client", Href = Url.Link("DeleteMyClient", new { id = client.Id }), Method = "DELETE" } } }); } if (TypesEqual <TDto, CreatedClientDto>()) { var client = (Domain.Entity.Client)domainEntity; return(new CreatedClientDto { Id = client.Id, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("GetClient", new { id = client.Id }), Method = "GET" }, new Link { Rel = "Update client", Href = Url.Link("UpdateClient", new { id = client.Id }), Method = "PUT" } } }); } if (TypesEqual <TDto, UpdatedClientDto>()) { var client = (Domain.Entity.Client)domainEntity; return(new UpdatedClientDto { Id = client.Id, UserId = client.UserId, Active = client.Active, AllowedOrigin = client.AllowedOrigin, ApplicationType = GetApplicationTypeString(client.ApplicationType), RefreshTokenLifeTime = client.RefreshTokenLifeTime, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("GetClient", new { id = client.Id }), Method = "GET" }, new Link { Rel = "Get user", Href = Url.Link("GetUser", new { id = client.UserId }), Method = "GET" }, new Link { Rel = "Update client", Href = Url.Link("UpdateClient", new { id = client.Id }), Method = "PUT" } } }); } return(null); }
internal static void MarkAsDeleted(this ICommonEntity entity) { entity.IsDeleted = true; entity.EntityDeletedDate = DateTime.UtcNow; }
public ICommonDto GetModel <TDto>(ICommonEntity domainEntity) where TDto : CommonDto { if (TypesEqual <TDto, RegisteredUserDto>()) { var user = (Domain.Entity.User)domainEntity; return(new RegisteredUserDto { Id = user.Id, Links = new List <Link> { new Link { Rel = "My account", Href = Url.Link("MyAccount", null), Method = "GET" }, new Link { Rel = "Resend activation link", Href = Url.Link("ResendActivationLink", null), Method = "POST" }, new Link { Rel = "Add new client", Href = Url.Link("UserCreateClient", null), Method = "POST" }, new Link { Rel = "Change password", Href = Url.Link("ChangePassword", null), Method = "POST" }, new Link { Rel = "Update my account", Href = Url.Link("UpdateMyAccount", null), Method = "PUT" }, new Link { Rel = "Delete account", Href = Url.Link("DeleteAccount", null), Method = "GET" } } }); } if (TypesEqual <TDto, MyAccountDto>()) { var user = (Domain.Entity.User)domainEntity; return(new MyAccountDto { Id = user.Id, Email = user.Email, UserName = user.UserName, FirstName = user.FirstName, LastName = user.LastName, Gender = GetGenderString(user.Gender), BirthDate = user.BirthDate, JoinDate = user.JoinDate, Roles = user.Roles, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("MyAccount", null), Method = "GET" }, new Link { Rel = "Add new client", Href = Url.Link("UserCreateClient", null), Method = "POST" }, new Link { Rel = "My clients", Href = Url.Link("MyClients", null), Method = "GET" }, new Link { Rel = "Resend activation link", Href = Url.Link("ResendActivationLink", null), Method = "POST" }, new Link { Rel = "Change password", Href = Url.Link("ChangePassword", null), Method = "POST" }, new Link { Rel = "Update my account", Href = Url.Link("UpdateMyAccount", null), Method = "PUT" }, new Link { Rel = "Delete account", Href = Url.Link("DeleteAccount", null), Method = "GET" } } }); } if (TypesEqual <TDto, UserDto>()) { var user = (Domain.Entity.User)domainEntity; return(new UserDto { Id = user.Id, Email = user.Email, UserName = user.UserName, FirstName = user.FirstName, LastName = user.LastName, Gender = GetGenderString(user.Gender), BirthDate = user.BirthDate, JoinDate = user.JoinDate, AccessFailedCount = user.AccessFailedCount, LockoutEndDateUtc = user.LockoutEndDateUtc, PhoneNumber = user.PhoneNumber, IsActive = user.IsActive, IsBanned = user.IsBanned, EmailConfirmed = user.EmailConfirmed, PhoneNumberConfirmed = user.PhoneNumberConfirmed, TwoFactorEnabled = user.TwoFactorEnabled, LockoutEnabled = user.LockoutEnabled, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("GetUser", new { id = user.Id }), Method = "GET" }, new Link { Rel = "User roles", Href = Url.Link("GetUserRoles", new { id = user.Id }), Method = "GET" }, new Link { Rel = "User clients", Href = Url.Link("GetUserClients", new { id = user.Id }), Method = "GET" }, new Link { Rel = "Add roles to user", Href = Url.Link("AddRolesToUser", new { id = user.Id }), Method = "POST" }, new Link { Rel = "Remove roles from user", Href = Url.Link("RemoveRolesFromUser", new { id = user.Id }), Method = "POST" } } }); } return(null); }
public ICommonDto GetModel <TDto>(ICommonEntity domainEntity) where TDto : CommonDto { if (TypesEqual <TDto, MovieDto>()) { var movie = (Domain.Entity.Movie)domainEntity; return(new MovieDto { Id = movie.Id, Title = movie.Title, PremiereDate = movie.PremiereDate.ToString("d"), Actors = movie.Actors, Directors = movie.Directors, ProductionCompany = movie.ProductionCompany, Categories = movie.Categories, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("GetMovie", new { id = movie.Id }), Method = "GET" }, new Link { Rel = "Update movie", Href = Url.Link("UpdateMovie", new { id = movie.Id }), Method = "PUT" }, new Link { Rel = "Delete movie", Href = Url.Link("DeleteMovie", new { id = movie.Id }), Method = "DELETE" }, new Link { Rel = "Add actors", Href = Url.Link("AddActors", new { id = movie.Id }), Method = "POST" }, new Link { Rel = "Add directors", Href = Url.Link("AddDirectors", new { id = movie.Id }), Method = "POST" }, new Link { Rel = "Add categories", Href = Url.Link("AddCategories", new { id = movie.Id }), Method = "POST" }, new Link { Rel = "Remove actors", Href = Url.Link("RemoveActors", new { id = movie.Id }), Method = "POST" }, new Link { Rel = "Remove directors", Href = Url.Link("RemoveDirectors", new { id = movie.Id }), Method = "POST" }, new Link { Rel = "Remove categories", Href = Url.Link("RemoveCategories", new { id = movie.Id }), Method = "POST" } } }); } if (TypesEqual <TDto, CreatedMovieDto>()) { var movie = (Domain.Entity.Movie)domainEntity; return(new CreatedMovieDto { Id = movie.Id, Links = new List <Link> { new Link { Rel = "Self", Href = Url.Link("GetMovie", new { id = movie.Id }), Method = "GET" } } }); } return(null); }
public long Add(ICommonEntity task) { throw new NotImplementedException(); }
public bool Add(ICommonEntity commonEntity) { throw new NotImplementedException(); }
public bool Edit(ICommonEntity commonEntity, int ID) { throw new NotImplementedException(); }
internal static void MarkAsUpdated(this ICommonEntity entity) { entity.EntityUpdatedDate = DateTime.UtcNow; }
/// <summary> /// Saves or updates the entities having reference to <see cref="ICommonEntity"/> interface. /// </summary> /// <param name="iCommonEntity"><see cref="ICommonEntity"/> interface</param> /// <param name="isCopy">If set to <c>true</c> SaveOrUpdateCopy will be used, else SaveOrUpdate.</param> public void SaveOrUpdateCommonEntity(ICommonEntity iCommonEntity, bool isCopy) { try { GenericGateway genericGateway = new GenericGateway(); genericGateway.SaveOrUpdateEntity<ICommon>(CommonMapper.GetCommonEntity<ICommonEntity>(iCommonEntity), isCopy); } catch (Exception ex) { Logger.Error("Error at SaveOrUpdateCommonEntity", ex); Logger.Error("Error in SaveOrUpdateCommonEntity: Message - " + ex.Message + " StackTrace - " + ex.StackTrace); throw; } }