public virtual void AddBoard(Board board) { if (_boards.Contains(board)) { _boards.Add(board); } }
public AccountRegisterResponseModel Register([FromBody] AccountRegisterModel model) { var validateMessage = _registerValidator.Validate(model); if (!String.IsNullOrEmpty(validateMessage)) { return new AccountRegisterResponseModel() { Message = validateMessage, Status = 1 }; } var accountExist = _readOnlyRepository.First<Account>( account1 => account1.Email == model.Email); if (accountExist == null) { Account account = _mappingEngine.Map<AccountRegisterModel, Account>(model); var encryptObj = new EncryptServices(); encryptObj.GenerateKeys(); account.Password = encryptObj.EncryptStringToBytes(account.Password, encryptObj.myRijndael.Key, encryptObj.myRijndael.IV); account.EncryptKey = encryptObj.myRijndael.Key; account.EncryptIV = encryptObj.myRijndael.IV; //AccountSeeder(accountCreated); var initboard = new Board() { Title = "Welcome Board"}; var lanes = Builder<Lane>.CreateListOfSize(3).Build(); lanes[0].Title = "To Do"; lanes[0].IsArchived = false; lanes[1].Title = "Doing"; lanes[1].IsArchived = false; lanes[2].Title = "Done"; lanes[2].IsArchived = false; foreach (var lane in lanes) { _writeOnlyRepository.Create(lane); } initboard.AddLane(lanes[0]); initboard.AddLane(lanes[1]); initboard.AddLane(lanes[2]); _writeOnlyRepository.Create(initboard); var organization = new Organization() { Title = "My Boards", Description = "Default Organization" }; organization.AddBoard(initboard); _writeOnlyRepository.Create(organization); account.AddOrganization(organization); Account accountCreated = _writeOnlyRepository.Create(account); initboard.Administrator = accountCreated; _writeOnlyRepository.Update(initboard); if (accountCreated != null) { SendSimpleMessage(accountCreated.FirstName, accountCreated.LastName, accountCreated.Email, model.Password); return new AccountRegisterResponseModel(accountCreated.Email, accountCreated.FirstName, 2); } return new AccountRegisterResponseModel() { Message = "Hubo un error al guardar el usuario", Status = 0 }; } return new AccountRegisterResponseModel(model.Email, model.FirstName, 0); }
public ReturnModel GetOrganizations(long organizationId, string accessToken) { var account = _readOnlyRepository.First<Account>(account1 => account1.Token == accessToken); ReturnModel remodel = new ReturnModel(); if (account != null) { if (account.VerifyToken(account)) { var organization = _readOnlyRepository.GetById<Organization>(organizationId); if (organization != null) { ReturnBoardsModel boardsModel = _mappingEngine.Map<Organization, ReturnBoardsModel>(organization); var boards = new ReturnBoardsModel(); boards.Boards = new List<Board>(); foreach (var or in boardsModel.Boards) { if (!or.IsArchived) { var o = new Board(); //o.Administrator = or.Administrator; o.Title = or.Title; o.Id = or.Id; boards.Boards.Add(o); } } return boards.ConfigureModel("Successfull", "", boards); } } return remodel.ConfigureModel("Error", "Su session ya expiro", remodel); } return remodel.ConfigureModel("Error", "No se pudo acceder a su cuenta", remodel); }