public async Task <IActionResult> AddEquipment([FromBody] EquipmentDto equipmentDto)
        {
            //nieuwzglenianie case sensitivity
            equipmentDto.EqName = equipmentDto.EqName.ToLower();

            if (await _repo.ValidateEquipmentName(equipmentDto.EqName, equipmentDto.UserId))
            {
                return(BadRequest("Taka nazwa ekwipunku już istnieje"));
            }


            var eqToCreate = new Equipments
            {
                EqName       = equipmentDto.EqName,
                UserId       = equipmentDto.UserId,
                HeroId       = equipmentDto.HeroId,
                FirtItemId   = equipmentDto.FirtItemId,
                SecondItemId = equipmentDto.SecondItemId,
                ThirdItemId  = equipmentDto.ThirdItemId,
                FourthItemId = equipmentDto.FourthItemId,
                FifthItemId  = equipmentDto.FifthItemId,
                SixthItemId  = equipmentDto.SixthItemId,
                GameId       = equipmentDto.GameId
            };

            var createdEquipment = await _repo.AddEquipment(eqToCreate, equipmentDto.HeroLvl);

            return(StatusCode(201));
        }
Beispiel #2
0
        public int AddEquipment(EquipmentDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(EquipmentDTO.FormatEquipmentDTO(dto));

                R_Equipment t = EquipmentDTO.ConvertDTOtoEntity(dto);

                // add
                id = Repository.AddEquipment(t);
                dto.EquipmentId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
        public async Task <IActionResult> CreateEquipment([FromBody] EquipmentParamModel model)
        {
            try
            {
                await _equipmentRepository.AddEquipment(model.Name, model.EquipmentType, model.RepairId);

                return(Json(
                           new
                {
                    Success = true,
                    Data = "Ok"
                }));
            }
            catch (Exception exception)
            {
                return(Json(new { Success = false, exception.Message }));
            }
        }
Beispiel #4
0
        public void AddEquipment(ISimulatedEquipment equipment)
        {
            if (equipment.Position < 0 || equipment.Position > Length - 1)
            {
                throw new SimulationException("The equipment position " + equipment.Position + " exceeds the ModuleSimulator range of " + Name);
            }

            _equipmentRepository.AddEquipment(equipment, this);

            _simulatedEquipments.Add(equipment);

            var taktPart = equipment as ITakt;

            if (taktPart != null)
            {
                TaktPartsRepository.AddTaktPart(taktPart);
            }
        }
Beispiel #5
0
        public IActionResult AddToCart([FromForm] Equipment equipment)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _equipmentRepository.AddEquipment(equipment);
                    return(RedirectToAction("Confirm"));
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    return(RedirectToAction("Error"));
                }
            }

            Log.Error("Invalid model state.");
            return(RedirectToAction("Error"));
        }
        public ResponseWrapper <object> AddEquipment(string equipmentName, int typeId)
        {
            try
            {
                var freeId       = GetEquipmentFreeId();
                var newEquipment = new SailingEquipment()
                {
                    equipmentId   = freeId,
                    equipmentName = equipmentName,
                    equipmentType = typeId
                };

                equipmentRepository.AddEquipment(newEquipment);
                equipmentRepository.Save();
                return(new ResponseWrapper <object>("OK", true));
            }
            catch (Exception e)
            {
                return(new ResponseWrapper <object>(e.Message, false));
            }
        }
Beispiel #7
0
        public override async Task <Confirmation> AddEquipment(EquipmentToAdd request, ServerCallContext context)
        {
            Equipment equipment = _mapper.Map <Equipment>(request);



            var precipitate = await _validator.ValidateAsync(equipment);

            if (precipitate.IsValid)
            {
                return(await _repo.AddEquipment(equipment));
            }
            else
            {
                return new Confirmation()
                       {
                           Code    = 404,
                           Message = precipitate.ToString()
                       }
            };
        }
 public async Task AddEquipmentSV(EquipmentInfoVM equipment)
 {
     await _equipment.AddEquipment(equipment);
 }
        public Equipments AddEquipment(Equipments equipments)
        {
            Equipments eq = _equipmentRepository.AddEquipment(equipments);

            return(eq);
        }
Beispiel #10
0
 public async Task <EquipmentResponse> Post([FromBody] EquipmentCreateRequest values)
 {
     return(await _equipment.AddEquipment(values));
 }
Beispiel #11
0
 public Equipment AddEquipment(Equipment equipment)
 {
     return(_equipmentRepository.AddEquipment(equipment));
 }
Beispiel #12
0
 public async Task AddEquipment(EquipmentToAddDto equipmentToAdd)
 {
     var companyId = (Guid)_soldierRepository.GetById(equipmentToAdd.SoldierId).Result.CompanyId;
     await _equipmentRepository.AddEquipment(EquipmentMapper.AddEquipmentMap(equipmentToAdd, companyId));
 }