Ejemplo n.º 1
0
        public virtual IActionResult PutTower([FromBody] TowerViewModel towerViewModel)
        {
            try
            {
                towerViewModel.UserId = UserId;
                var existingTower = TowerRepository.Find(towerViewModel.TowerId);

                if (existingTower != null)
                {
                    if (towerViewModel.TowerId > 0)
                    {
                        towerViewModel.Adapt(existingTower);
                        TowerRepository.Update(existingTower);

                        return(new ObjectResult(new OperationResult {
                            IsSuccess = true, ErrorMessage = "Tower Updated Successfully"
                        }));
                    }
                    else
                    {
                        return(new ObjectResult(new OperationResult {
                            IsSuccess = false, ErrorMessage = "Not Updated"
                        }));
                    }
                }
                else
                {
                    return(new ObjectResult(new OperationResult {
                        IsSuccess = false, ErrorMessage = "tower does not exist"
                    }));
                }
            }
            catch (Exception ex)
            {
                return(new ObjectResult(new OperationResult {
                    IsSuccess = false, ErrorMessage = ex.Message
                }));
            }
        }