Inheritance: EncodableDTO
Ejemplo n.º 1
0
        public static void Update(PartDTO partDTO)
        {
            string sql = "update Part set Name =('" + partDTO.Name + "'), Sign =('" + partDTO.Sign + "'), Amount =(" + partDTO.Amount + "), Limit =("
                         + partDTO.Limit + ") where PartID =" + partDTO.Id + "";

            Database.ExcuNonQuery(sql);
        }
Ejemplo n.º 2
0
        public PartDTO WritePartDto(Part part)
        {
            var partDto = new PartDTO();

            partDto.PartNumber          = part.PartNumber;
            partDto.UnitOfMeasure       = part.UnitOfMeasure;
            partDto.ExtendedDescription = part.ExtendedDescription;
            partDto.PartDescription     = part.PartDescription;
            partDto.SalesCode           = part.SalesCode;
            var componentsList = part.Components
                                 .Select(component => new ComponentDTO()
            {
                Number              = component.ComponentNumber,
                Description         = component.ComponentDescription,
                Material            = component.Material,
                UnitOfMeasure       = component.UnitOfMeasure,
                QuantityPerAssembly = component.QuantityPerAssembly,
                CostPerUnit         = component.CostPerUnit
            }).ToList();
            var laborSequenceList = part.LaborSequences
                                    .Select(labor => new LaborSequenceDTO()
            {
                LaborSequenceNumber = labor.LaborSequenceNumber,
                LaborSequenceDesc   = labor.LaborSequenceDesc,
                RunTime             = labor.RunTime,
                LaborRate           = labor.LaborRate,
                Burden = labor.Burden
            }).ToList();

            partDto.Components = componentsList;
            partDto.Labor      = laborSequenceList;

            return(partDto);
        }
Ejemplo n.º 3
0
        public IEnumerable <PartDTO> GetReportDetails(PartDTO partDTO)
        {
            var parts = _bheUOW.PartsRepository.Query();

            if (!string.IsNullOrEmpty(partDTO.PartNumber))
            {
                parts = parts.Where(x => x.PartNumber == partDTO.PartNumber);
            }
            if (!string.IsNullOrEmpty(partDTO.Make) && partDTO.Make != "All")
            {
                parts = parts.Where(x => x.Make == partDTO.Make);
            }
            if (!string.IsNullOrEmpty(partDTO.Model))
            {
                parts = parts.Where(x => x.Model == partDTO.Model);
            }

            if (!string.IsNullOrEmpty(partDTO.PartDescription))
            {
                parts = parts.Where(x => x.PartDescription.Contains(partDTO.PartDescription));
            }
            if (!string.IsNullOrEmpty(partDTO.PartManual))
            {
                parts = parts.Where(x => x.PartManual.Contains(partDTO.PartManual));
            }
            if (!string.IsNullOrEmpty(partDTO.SerialNumberRange))
            {
                parts = parts.Where(x => x.SerialNumberRange.Contains(partDTO.SerialNumberRange));
            }

            return(parts.ToList().ConvertAll(PartDTOMapper));
        }
Ejemplo n.º 4
0
        public long Add(PartDTO partDTO)
        {
            try
            {
                Part part = new Part()
                {
                    CompanyID         = partDTO.CompanyID,
                    ListPrice         = partDTO.ListPrice,
                    Make              = partDTO.Make,
                    Model             = partDTO.Model,
                    PartDescription   = partDTO.PartDescription,
                    PartManual        = partDTO.PartManual,
                    PartNumber        = partDTO.PartNumber,
                    SerialNumberRange = partDTO.SerialNumberRange,
                    AddedBy           = "Admin",
                    AddedDate         = DateTime.Now,
                    IsDeleted         = false
                };

                var partID = _bheUOW.PartsRepository.Add(part);
                _bheUOW.SaveChanges();
                return(partID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
0
        public IEnumerable <BikeDTO> GetBikes()
        {
            return(_bikeRepository.GetAll().Select(b =>
            {
                return new BikeDTO
                {
                    Id = b.Id,
                    Name = b.Name,
                    Type = b.Type,
                    Parts = b.Parts.Select(p =>
                    {
                        PartDTO part = new PartDTO
                        {
                            Id = p.Part.Id,
                            Name = p.Part.Name,
                            Description = p.Part.Description,
                            Functionality = p.Part.Functionality.ToString(),
                            IsOptional = p.Part.IsOptional,
                            DominantParts = p.Part.DominantParts.Select(dp => dp.DominantPart.Name).ToList(),
                            DependantParts = p.Part.DependantParts.Select(dp => dp.DependantPart.Name).ToList(),
                            BikeId = p.Part.BikeParts.Select(b => b.BikeId).ToList()
                        };

                        return part;
                    }).OrderBy(p => p.Name).ToList()
                };
            }).ToList());
        }
        public HttpResponseMessage GetPartsDetails(PartDTO partDTO)
        {
            //PartDTO partDTO = new PartDTO();
            var partsList = _partBL.GetReportDetails(partDTO);

            return(_httpResponseMessageBuilder.GetResponse(partsList, Request));
        }
Ejemplo n.º 7
0
        public ActionResult GetPartsReport(PartDTO part)
        {
            try
            {
                Parts parts = new Parts();
                InitializeReportViewer();
                //List<PartDTO> parts = GetPartData(part);
                List <PartDTO> partsList = parts.GetPartData(part);

                if (partsList != null && partsList.Count > 0)
                {
                    if (partsList.Count > 10000)
                    {
                        ViewBag.MaxRecordExceed = " Search results exceed maximum limit of 10,000 records, please refine the 'Search Terms' and try again";
                    }
                    else
                    {
                        string path = Path.Combine(Server.MapPath("~/BrownsReports"), "rpdPart.rdlc");
                        _reportViewer.LocalReport.ReportPath = path;
                        _reportViewer.LocalReport.DataSources.Add(new ReportDataSource("BHEDS", partsList));
                        ViewBag.ReportViewer = _reportViewer;
                    }
                }
                ViewBag.OnLoad = "OnReportLoading";

                return(View("Index"));
            }
            catch (Exception ex)
            {
                WrapLogException(ex);
                return(null);
            }
        }
Ejemplo n.º 8
0
        public async Task <List <PartDTO> > Search(PartSearchCriteria searchCriteria)
        {
            var partList = await this.FindParts(searchCriteria);

            var partListDTO = new List <PartDTO>();

            foreach (var p in partList)
            {
                var partDto = new PartDTO
                {
                    PartId         = p.PartId,
                    ItemId         = p.ItemId,
                    ItemName       = p.ItemName,
                    CategoryId     = p.CategoryId,
                    IconLink       = p.IconLink,
                    ImageLink      = p.ImageLink,
                    ItemDimensionX = p.ItemDimensionX,
                    ItemDimensionY = p.ItemDimensionY,
                    ItemDimensionZ = p.ItemDimensionZ,
                    ItemTypeId     = p.ItemTypeId,
                    ItemTypeName   = p.ItemType.ItemTypeName,
                    CategoryName   = p.Category.Name,
                    Quantity       = p.Quantity,
                    ColorCount     = p.ColorQuantity
                };

                partDto.PartColors = await PartColors(p.ItemId);

                partListDTO.Add(partDto);
            }

            return(partListDTO);
        }
Ejemplo n.º 9
0
        public ActionResult <BikeDTO> GetBikeByName(string name)
        {
            try
            {
                Bike    bike    = _bikeRepository.GetByName(name);
                BikeDTO bikeDTO = new BikeDTO
                {
                    Id    = bike.Id,
                    Name  = bike.Name,
                    Parts = bike.Parts.Select(p =>
                    {
                        PartDTO part = new PartDTO
                        {
                            Id             = p.Part.Id,
                            Name           = p.Part.Name,
                            Description    = p.Part.Description,
                            Functionality  = p.Part.Functionality.ToString(),
                            IsOptional     = p.Part.IsOptional,
                            DominantParts  = p.Part.DominantParts.Select(dp => dp.DominantPart.Name).ToList(),
                            DependantParts = p.Part.DependantParts.Select(dp => dp.DependantPart.Name).ToList(),
                            BikeId         = p.Part.BikeParts.Select(b => b.BikeId).ToList()
                        };

                        return(part);
                    }).OrderBy(p => p.Name).ToList(),
                    Type = bike.Type
                };
                return(Ok(bikeDTO));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
        public async Task PartService_Should_Update_Part()
        {
            // Arrange
            SetUpUnitOfWork();
            var service = new PartService(_unitOfWork.Object, _mapper);
            var entity  = new PartDTO()
            {
                Name = "TestName",
                Code = "12345",
            };

            var newEntity = new PartDTO()
            {
                Name = "NewTestName",
                Code = "12345678",
            };

            await service.CreateAsync(entity);

            await _unitOfWork.Object.SaveAsync();

            // Act
            entity.Name = newEntity.Name;
            entity.Code = newEntity.Code;
            await service.UpdateAsync(entity);

            await _unitOfWork.Object.SaveAsync();

            // Assert
            Assert.NotNull(entity);
            Assert.Equal(newEntity.Name, entity.Name);
            Assert.Equal(newEntity.Code, entity.Code);
        }
Ejemplo n.º 11
0
        public static void Insert(PartDTO partDTO)
        {
            string sql = "insert into Part(PartID, PartName, Sign, Amount, Limit) values ('" + partDTO.Id + "', '" + partDTO.Name + "', '" +
                         partDTO.Sign + "', " + partDTO.Amount + ", " + partDTO.Limit + ")";

            Database.ExcuNonQuery(sql);
        }
Ejemplo n.º 12
0
        public async Task <PartDTO> UpdateAsync(PartDTO dto)
        {
            var model = _mapper.Map <Part>(dto);

            _unitOfWork.PartRepository.Update(model);
            await _unitOfWork.SaveAsync();

            return(_mapper.Map <PartDTO>(model));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> Add([FromRoute] string buildingId, [FromBody] PartDTO request)
        {
            await _mediator.Send(new CreatePartCommand
            {
                BuildingExternalId = buildingId,
                Name      = request.Name,
                Budget    = request.Budget,
                EndDate   = request.EndDate,
                StartDate = request.StartDate
            });

            return(Ok());
        }
Ejemplo n.º 14
0
        public void Execute(PartDTO partDto)
        {
            using (_context = new CarHistoryContext())
            {
                //_context.Database.CreateIfNotExists();
                DB.Domain.Part part = new DB.Domain.Part();
                part.Name = partDto.Name;


                _context.Parts.Add(part);
                _context.SaveChanges();
            }
        }
Ejemplo n.º 15
0
        private void updatePart()
        {
            PartDTO partDTO = new PartDTO();

            partDTO.Id     = tbPartIdEdit.Text;
            partDTO.Name   = tbPartNameEdit.Text;
            partDTO.Sign   = tbPartSignEdit.Text;
            partDTO.Amount = int.Parse(tbPartAmountEdit.Text);
            partDTO.Limit  = int.Parse(tbPartIdEdit.Text);

            PartDAO.Update(partDTO);
            loadPartList();
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> Update([FromRoute] string id, [FromBody] PartDTO request)
        {
            await _mediator.Send(new UpdatePartCommand
            {
                EndDate        = request.EndDate,
                Budget         = request.Budget,
                Name           = request.Name,
                PartExternalId = id,
                StartDate      = request.StartDate
            });

            return(Ok());
        }
Ejemplo n.º 17
0
        private void createPart()
        {
            PartDTO partDTO = new PartDTO();

            partDTO.Id     = tbPartIdCreate.Text;
            partDTO.Name   = tbPartNameCreate.Text;
            partDTO.Sign   = tbPartSignCreate.Text;
            partDTO.Amount = int.Parse(tbPartAmountCreate.Text);
            partDTO.Limit  = int.Parse(tbPartIdCreate.Text);

            PartDAO.Insert(partDTO);
            loadPartList();
        }
Ejemplo n.º 18
0
        public List <PartDTO> GetPartListforReport(PartDTO partDTO)
        {
            HttpResponseMessage response = null;
            List <PartDTO>      plist    = null;

            _client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            response = _client.PostAsync("Part/GetReportDetails", new StringContent(
                                             new JavaScriptSerializer().Serialize(partDTO), Encoding.UTF8, "application/json")).Result;

            if (response.IsSuccessStatusCode)
            {
                plist = response.Content.ReadAsAsync <List <PartDTO> >().Result;
            }

            return(plist);
        }
Ejemplo n.º 19
0
        public long Delete(PartDTO partDTO)
        {
            Part part = new Part()
            {
                CompanyID         = partDTO.CompanyID,
                ListPrice         = partDTO.ListPrice,
                Make              = partDTO.Make,
                Model             = partDTO.Model,
                PartDescription   = partDTO.PartDescription,
                PartManual        = partDTO.PartManual,
                PartNumber        = partDTO.PartNumber,
                SerialNumberRange = partDTO.SerialNumberRange,
                ID = partDTO.ID
            };

            var partID = _bheUOW.PartsRepository.Delete(part);

            _bheUOW.SaveChanges();
            return(partID);
        }
        public async Task PartService_Should_Create_Part_Async()
        {
            // Arrange
            SetUpUnitOfWork();
            var service        = new PartService(_unitOfWork.Object, _mapper);
            var expectedEntity = new PartDTO()
            {
                Name = "TestName",
                Code = "12345",
            };

            // Act
            var actualEntity = await service.CreateAsync(expectedEntity);

            await _unitOfWork.Object.SaveAsync();

            // Assert
            Assert.NotNull(actualEntity);
            Assert.Equal(expectedEntity.Name, actualEntity.Name);
            Assert.Equal(expectedEntity.Code, actualEntity.Code);
        }
        public async Task PartService_Should_Delete_Part_Async()
        {
            // Arrange
            SetUpUnitOfWork();
            var service = new PartService(_unitOfWork.Object, _mapper);
            var entity  = new PartDTO()
            {
                Name = "TestName",
                Code = "12345"
            };

            entity = await service.CreateAsync(entity);

            await _unitOfWork.Object.SaveAsync();

            // Act
            await service.DeleteAsync(entity.Id);

            await _unitOfWork.Object.SaveAsync();

            // Assert
            Assert.Null(await service.GetAsync(entity.Id));
        }
Ejemplo n.º 22
0
        public long Update(PartDTO partDTO)
        {
            long ID           = -1;
            var  existingPart = _bheUOW.PartsRepository.Query().SingleOrDefault(x => x.ID == partDTO.ID);

            if (existingPart != null)
            {
                existingPart.CompanyID         = partDTO.CompanyID;
                existingPart.ListPrice         = partDTO.ListPrice;
                existingPart.Make              = partDTO.Make;
                existingPart.Model             = partDTO.Model;
                existingPart.PartDescription   = partDTO.PartDescription;
                existingPart.PartManual        = partDTO.PartManual;
                existingPart.PartNumber        = partDTO.PartNumber;
                existingPart.SerialNumberRange = partDTO.SerialNumberRange;
                existingPart.LastUpdatedBy     = "Admin";
                existingPart.LastUpdatedDate   = DateTime.Now;
                existingPart.IsDeleted         = false;
                _bheUOW.SaveChanges();
                ID = existingPart.ID;
            }
            return(ID);
        }
Ejemplo n.º 23
0
        public ActionResult <PartDTO> GetById(int id)
        {
            Part p = _partRepository.GetById(id);

            if (p == null)
            {
                return(NotFound());
            }

            PartDTO partDTO = new PartDTO
            {
                Id             = p.Id,
                Name           = p.Name,
                Description    = p.Description,
                Functionality  = p.Functionality.ToString(),
                IsOptional     = p.IsOptional,
                DominantParts  = p.DominantParts.Select(dp => dp.DominantPart.Name).ToList(),
                DependantParts = p.DependantParts.Select(dp => dp.DependantPart.Name).ToList(),
                BikeId         = p.BikeParts.Select(b => b.BikeId).ToList()
            };

            return(Ok(partDTO));
        }
Ejemplo n.º 24
0
        public List <PartDTO> GetPartData(PartDTO partDTO)
        {
            try
            {
                SqlCommand command = new SqlCommand();

                ISqlConnectionHelper sqlHelper = new SqlConnectionHelper(ConfigurationManager.ConnectionStrings["BrownsAppDBConnectionString"].ConnectionString);
                DataTable            dtResults = new DataTable();
                DataSet dsResults = new DataSet();

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "dbo.GetPartReportData";

                command.Parameters.AddWithValue("@Make", string.IsNullOrEmpty(partDTO.Make) ? null : partDTO.Make.Trim());
                command.Parameters.AddWithValue("@Model", string.IsNullOrEmpty(partDTO.Model) ? null : partDTO.Model.Trim());
                command.Parameters.AddWithValue("@SerialNumberRange", string.IsNullOrEmpty(partDTO.SerialNumberRange) ? null : partDTO.SerialNumberRange.Trim());
                command.Parameters.AddWithValue("@PartNumber", string.IsNullOrEmpty(partDTO.PartNumber) ? null : partDTO.PartNumber.Trim());
                command.Parameters.AddWithValue("@PartManual", string.IsNullOrEmpty(partDTO.PartManual) ? null : partDTO.PartManual.Trim());
                command.Parameters.AddWithValue("@PartDescription", string.IsNullOrEmpty(partDTO.PartDescription) ? null : partDTO.PartDescription.Trim());

                dsResults = sqlHelper.ExecuteStoredProcedure(command);
                if (dsResults != null && dsResults.Tables.Count > 0)
                {
                    return(ConvertToList(dsResults));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler exceptionHandler = new ExceptionHandler();
                exceptionHandler.WrapLogException(ex);
                return(null);
            }
        }
        public HttpResponseMessage Delete(PartDTO partDTO)
        {
            var partID = _partBL.Delete(partDTO);

            return(_httpResponseMessageBuilder.GetSimpleResponse(partID, Request));
        }
        public HttpResponseMessage Put(PartDTO partDTO)
        {
            var part = _partBL.Update(partDTO);

            return(_httpResponseMessageBuilder.GetSimpleResponse(part, Request));
        }
Ejemplo n.º 27
0
        public IEnumerable <PartDTO> Get([FromQuery] QueryParams queryParams)
        {
            List <PartDTO> rows = new List <PartDTO>();


            using (TextFieldParser parser = new TextFieldParser(@"/Users/karukenert/Documents/projects.tmp/WebApplicationVaruosad/LE.txt")) {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters("\t");
                while (!parser.EndOfData)
                {
                    //Processing row
                    string[] columns = parser.ReadFields();
                    var      part    = new PartDTO();
                    part.Serial   = columns[0];
                    part.Name     = columns[1];
                    part.Price    = columns[8];
                    part.PriceVAT = columns[10];
                    part.CarModel = columns[9];

                    int stockCount = 0;
                    int.TryParse(columns[2], out stockCount);
                    part.Stock.Add("Tallinn", stockCount);
                    int.TryParse(columns[3], out stockCount);
                    part.Stock.Add("Tartu", stockCount);
                    int.TryParse(columns[4], out stockCount);
                    part.Stock.Add("Pärnu", stockCount);
                    int.TryParse(columns[5], out stockCount);
                    part.Stock.Add("Kohta-Järve", stockCount);
                    int.TryParse(columns[6], out stockCount);

                    rows.Add(part);
                }
            }

            var query = rows.AsQueryable();

            // Nime järgi otsimine - works
            if (queryParams.Name.Length > 0)
            {
                query = query.Where(row => row.Name.ToLower().Contains(queryParams.Name.ToLower()));
            }

            // Seerianumbri järgi otsimine - works
            if (queryParams.Serial.Length > 0)
            {
                query = query.Where(row => row.Serial == queryParams.Serial);
            }

            NumberFormatInfo provider = new NumberFormatInfo();

            provider.NumberDecimalSeparator = ",";

            //Sorting - works
            if (queryParams.Sort.ToLower() == "price")
            {
                query = query.OrderBy(item => Convert.ToDouble(item.Price, provider));
            }
            else if (queryParams.Sort.ToLower() == "-price")
            {
                query = query.OrderByDescending(item => Convert.ToDouble(item.Price, provider));
            }


            query = query.Skip((queryParams.Page - 1) * queryParams.PageSize).Take(queryParams.PageSize);

            return(query.ToList());
        }