public HttpResponseMessage GenerateProcuratory(int auctionId, int lotId)
        {
            var auction     = DataManager.GetAuction(auctionId);
            var lotExtended = DataManager.GetLotsExtended(lotId);

            if (auction == null || !auction.Lots.Any(l => l.Id == lotId) || lotExtended.Count == 0)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var templateRequisite = ArchiveManager.GetTemplateRequisite((MarketPlaceEnum)auction.SiteId, DocumentTemplateEnum.TechSpec);

            if (templateRequisite == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotImplemented);
            }

            var localPath = ArchiveManager.LoadTemplateToLocalStorage(templateRequisite);
            var fileName  = string.Format("{0}_{1}.{2}", TECH_SPEC_FILE_NAME, auction.Lots.First(l => l.Id == lotId).Number, templateRequisite.extension);

            TechSpecService.CreateDocument(localPath, lotExtended);
            var responceFile = HttpResponceFile.Create(fileName, localPath);

            if (responceFile == null)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(responceFile);
        }
        public HttpResponseMessage UpdateTechSpecUseTemplate(int auctionId, int lotId)
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.MethodNotAllowed);
            }

            var auction     = DataManager.GetAuction(auctionId);
            var finalReport = DataManager.GetFinalReport(auctionId, lotId, CurrentUser.SupplierId);

            if (auction.StatusId != 2 || finalReport == null)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            var file      = HttpContext.Current.Request.Files.Get("file");
            var localPath = string.Format("{0}/{1}_{2}", HttpContext.Current.Server.MapPath("~/App_Data"), Guid.NewGuid(), file.FileName);

            file.SaveAs(localPath);
            var lot = DataManager.GetLot(lotId);

            if (lot == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            var NewLotExtended = new List <LotsExtended>();

            if (!TechSpecService.ParseDocument(localPath, lot.LotsExtended.ToList(), out NewLotExtended))
            {
                throw new HttpResponseException(HttpStatusCode.Conflict);
            }
            return(UpdateTechSpec(auctionId, lotId, new FormTechSpec()
            {
                lotExtepdeds = NewLotExtended
            }));
        }