Beispiel #1
0
 //FUNÇÃO QUE PERMITE TRANSITAR DE ESTADO PARA OUTRO ESTADO
 public string TransistionTo(AbstractStatus state)
 {
     this._state = state;
     this._state.SetContext(this);
     this.Status = state.GetTypeOf();
     return(state.GetTypeOf());
 }
 public AbstractStatusViewModel(AbstractStatus abstractStatus)
 {
     if (abstractStatus == null)
     {
         throw new ArgumentNullException("abstractStatus");
     }
     this.Model = abstractStatus;
 }
Beispiel #3
0
 public AbstractStatus GetByID(int _abstractStatusId)
 {
     AbstractStatusDAC _abstractStatusComponent = new AbstractStatusDAC();
     IDataReader reader = _abstractStatusComponent.GetByIDAbstractStatus(_abstractStatusId);
     AbstractStatus _abstractStatus = null;
     while(reader.Read())
     {
         _abstractStatus = new AbstractStatus();
         if(reader["AbstractStatusId"] != DBNull.Value)
             _abstractStatus.AbstractStatusId = Convert.ToInt32(reader["AbstractStatusId"]);
         if(reader["Name"] != DBNull.Value)
             _abstractStatus.Name = Convert.ToString(reader["Name"]);
         if(reader["NameAr"] != DBNull.Value)
             _abstractStatus.NameAr = Convert.ToString(reader["NameAr"]);
     _abstractStatus.NewRecord = false;             }             reader.Close();
     return _abstractStatus;
 }
Beispiel #4
0
 public List<AbstractStatus> GetAll()
 {
     AbstractStatusDAC _abstractStatusComponent = new AbstractStatusDAC();
     IDataReader reader =  _abstractStatusComponent.GetAllAbstractStatus().CreateDataReader();
     List<AbstractStatus> _abstractStatusList = new List<AbstractStatus>();
     while(reader.Read())
     {
     if(_abstractStatusList == null)
         _abstractStatusList = new List<AbstractStatus>();
         AbstractStatus _abstractStatus = new AbstractStatus();
         if(reader["AbstractStatusId"] != DBNull.Value)
             _abstractStatus.AbstractStatusId = Convert.ToInt32(reader["AbstractStatusId"]);
         if(reader["Name"] != DBNull.Value)
             _abstractStatus.Name = Convert.ToString(reader["Name"]);
         if(reader["NameAr"] != DBNull.Value)
             _abstractStatus.NameAr = Convert.ToString(reader["NameAr"]);
     _abstractStatus.NewRecord = false;
     _abstractStatusList.Add(_abstractStatus);
     }             reader.Close();
     return _abstractStatusList;
 }
        public async Task <IActionResult> UpdateAssociation(Animal aAnimal)
        {
            var currentUser = HttpContext.User;

            try
            {
                if (currentUser.HasClaim(c => c.Type == "id"))
                {
                    AbstractStatus state = GetState(aAnimal.Id);

                    if (aAnimal.Status == "Adotado")
                    {
                        aAnimal.Status = aAnimal.StartAdopted(state);
                    }
                    else if (aAnimal.Status == "Perdido")
                    {
                        aAnimal.Status = aAnimal.StartLosted(state);
                    }
                    else if (aAnimal.Status == "Adoção")
                    {
                        aAnimal.Status = aAnimal.StartToAdoption(state);
                    }
                    else
                    {
                        return(BadRequest(notFound.TemplateResponse("Valor para o Status inválido")));
                    }
                    _context.Entry(await _context.Animals.FirstOrDefaultAsync(x => x.Id == aAnimal.Id)).CurrentValues.SetValues(aAnimal);
                    await _context.SaveChangesAsync();

                    object response = new { success = true, data = aAnimal };
                    return(Ok(response));
                }
                return(NotFound(notFound.TemplateResponse("Utilizador não se encontra autenticado")));
            }
            catch
            {
                return(NotFound(notFound.TemplateResponse($"Nao foi possivel atualizar o animal com o id {aAnimal.Id}")));
            }
        }
 public void addStatus(AbstractCreature c, AbstractStatus s)
 {
     statuses.Add(s);
     s.applyStatus(c);
 }
Beispiel #7
0
 public string  StartAdopted(AbstractStatus aCurrentStatus)
 {
     _state = aCurrentStatus;
     this._state.SetContext(this);
     return(this._state.AdoptedTo());
 }
Beispiel #8
0
 //AÇÃO REQUEST2
 public string StartToAdoption(AbstractStatus aCurrentStatus)
 {
     _state = aCurrentStatus;
     this._state.SetContext(this);
     return(this._state.ToAdoption());
 }
Beispiel #9
0
		public bool Update(AbstractStatus abstractstatus ,int old_abstractStatusId)
		{
			AbstractStatusDAC abstractstatusComponent = new AbstractStatusDAC();
			return abstractstatusComponent.UpdateAbstractStatus( abstractstatus.AbstractStatusId,  abstractstatus.Name,  abstractstatus.NameAr,  old_abstractStatusId);
		}
Beispiel #10
0
		public bool Insert(AbstractStatus abstractstatus)
		{
			AbstractStatusDAC abstractstatusComponent = new AbstractStatusDAC();
			return abstractstatusComponent.InsertNewAbstractStatus( abstractstatus.AbstractStatusId,  abstractstatus.Name,  abstractstatus.NameAr);
		}
Beispiel #11
0
 public void SetSuccessor(AbstractStatus successor)
 {
     this.successor = successor;
 }