public bool NewEmployee(EmployeeModel employee) { Employee emp = new Employee(); emp.EmployeeID = employee.EmployeeID; emp.FirstName = employee.FirstName; emp.MiddleName = employee.MiddleName; emp.LastName = employee.LastName; emp.ManagerID = employee.ManagerID; emp.Gender = employee.Gender; emp.PhoneNumber = employee.PhoneNumber; emp.EmailAddress = employee.EmailAddress; emp.DepartmentID = employee.DepartmentID; emp.PositionID = employee.PositionID; emp.IsCompany = employee.IsCompany; emp.CompanyName = employee.CompanyName; emp.Status = employee.Status; FastDB.Employees.Add(emp); FastDB.SaveChanges(); return(true); }
public bool UpdateEmployee(EmployeeModel employee) { var emp = (from k in FastDB.Employees where k.EmployeeID == employee.EmployeeID select k).FirstOrDefault(); emp.FirstName = employee.FirstName; emp.MiddleName = employee.MiddleName; emp.LastName = employee.LastName; emp.ManagerID = employee.ManagerID; emp.Gender = employee.Gender; emp.PhoneNumber = employee.PhoneNumber; emp.EmailAddress = employee.EmailAddress; emp.DepartmentID = employee.DepartmentID; emp.PositionID = employee.PositionID; emp.IsCompany = employee.IsCompany; emp.CompanyName = employee.CompanyName; emp.Status = employee.Status; //db.Employees.Add(emp); FastDB.SaveChanges(); return(true); }
public RegistrationStatus CreateNewUser(NewUserModel UserModel) { var hashedPassword = Encryption.MD5Hash(UserModel.Password); var hashedConfirmPassword = Encryption.MD5Hash(UserModel.ConfirmPassword); if (hashedPassword == hashedConfirmPassword) { bool EmployeeExists = FastDB.Employees.Where(k => k.EmployeeID == UserModel.EmployeeID).Any(); if (EmployeeExists) { bool IsEmployeeAlreadyRegistered = FastDB.Registrations.Where(k => k.EmployeeID == UserModel.EmployeeID).Any(); if (IsEmployeeAlreadyRegistered) { return(RegistrationStatus.EmployeeIDAlreadyExists); } else { // Main registration process starts here. Registration reg = new Registration(); reg.DateStamp = DateTime.Now; reg.Password = hashedPassword; reg.Status = 0; reg.EmployeeID = UserModel.EmployeeID; FastDB.Registrations.Add(reg); FastDB.SaveChanges(); return(RegistrationStatus.Successful); } } else { return(RegistrationStatus.EmployeeIDDontExists); } } else { return(RegistrationStatus.PasswordsDidNotMatch); } }
public bool NewAsset(FixAssetModel assetModel) { FixAsset asset = new FixAsset(); asset.Model = assetModel.Model; asset.SerialNumber = assetModel.SerialNumber; asset.AssetTag = assetModel.AssetTag; asset.Brand = assetModel.Brand; asset.Remarks = assetModel.Remarks; if (assetModel.AcquisitionDate != null) { asset.AcquisitionDate = assetModel.AcquisitionDate; } if (assetModel.ExpiryDate != null) { asset.ExpiryDate = assetModel.ExpiryDate; } if (assetModel.IssuerID != null) { asset.IssuerID = assetModel.IssuerID; } if (assetModel.LocationID != null) { asset.LocationID = assetModel.LocationID; } asset.AssetTypeID = assetModel.AssetTypeID; asset.AssetStatusID = assetModel.AssetStatusID; asset.AssetClassID = assetModel.AssetClassID; FastDB.FixAssets.Add(asset); FastDB.SaveChanges(); return(true); }
public bool UpdateAsset(FixAssetModel assetModel) { var asset = FastDB.FixAssets.Where(k => k.FixAssetID == assetModel.FixAssetID).FirstOrDefault(); asset.Model = assetModel.Model; asset.SerialNumber = assetModel.SerialNumber; asset.AssetTag = assetModel.AssetTag; asset.Brand = assetModel.Brand; asset.Remarks = assetModel.Remarks; if (assetModel.AcquisitionDate != null) { asset.AcquisitionDate = assetModel.AcquisitionDate; } if (assetModel.ExpiryDate != null) { asset.ExpiryDate = assetModel.ExpiryDate; } if (assetModel.IssuerID != null) { asset.IssuerID = assetModel.IssuerID; } if (assetModel.LocationID != null) { asset.LocationID = assetModel.LocationID; } asset.AssetTypeID = assetModel.AssetTypeID; asset.AssetStatusID = assetModel.AssetStatusID; asset.AssetClassID = assetModel.AssetClassID; FastDB.SaveChanges(); return(true); }