public async Task <IActionResult> IsAcssept(long?id, AcceptedTypes AccessTypeId, string Reason)
        {
            var product = await _context.Products.FindAsync(id);

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


            if (ModelState.IsValid)
            {
                try
                {
                    product.IsAccepted = AccessTypeId;
                    product.Reason     = Reason;
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            ViewData["CorroborantId"] = new SelectList(_context.Corroborants, "Id", "Id", product.CorroborantId);
            ViewData["ProductTypeId"] = new SelectList(_context.ProductTypes, "Id", "Id", product.ProductTypeId);
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("Id,StartDate,EndDate,CorroborantTypeId,Name")] Corroborant corroborant,
                                                 IFormFile UploadLinces, string startdate, string enddate)
        {
            FileManager fileManager = new FileManager(_enviroment);

            if (UploadLinces != null)
            {
                corroborant.UploadLinces = await fileManager.InsertFiles(UploadLinces, "image/Document");
            }

            DateTime sdate = Convert.ToDateTime(startdate);
            DateTime edate = Convert.ToDateTime(enddate);

            if (ModelState.IsValid)
            {
                corroborant.StartDate = sdate;
                corroborant.EndDate   = edate;
                _context.Add(corroborant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CorroborantTypeId"] = new SelectList(_context.Corroborants, "Id", "Id", corroborant.CorroborantTypeId);

            return(View(corroborant));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Name,RecordNumber,RecordDate,RecordPlace,CompanyStartDate," +
                                                       "FactoryStartDate,FactoryUseDate,NationalId,EconomicCode,UseLicenseNumber,UseLicenseDate," +
                                                       "ActivityDescription,MaterialList,Randd,ConstructionMetod,QcProgram,ResearchMember" +
                                                       ",CompanyTypeId,OwnershipTypeId,CarId,LicenseId")] Company company,
                                                 IFormFile UploadDocuments, IFormFile UploadUseLicensePic, IFormFile UploadStatutePic,
                                                 IFormFile UploadOfficialnewspapers, IFormFile UploadProductCatalog, IFormFile UploadMemberOfTheInstitute)
        {
            FileManager fileManager = new FileManager(_enviroment);

            if (UploadDocuments != null)
            {
                company.UploadDocuments = await fileManager.InsertFiles(UploadDocuments, "image/Document");
            }

            if (UploadUseLicensePic != null)
            {
                company.UploadUseLicensePic = await fileManager.InsertFiles(UploadUseLicensePic, "image/Document");
            }

            if (UploadStatutePic != null)
            {
                company.UploadStatutePic = await fileManager.InsertFiles(UploadStatutePic, "image/Document");
            }

            if (UploadOfficialnewspapers != null)
            {
                company.UploadOfficialnewspapers = await fileManager.InsertFiles(UploadOfficialnewspapers, "image/Document");
            }

            if (UploadProductCatalog != null)
            {
                company.UploadProductCatalog = await fileManager.InsertFiles(UploadProductCatalog, "image/Document");
            }

            if (UploadMemberOfTheInstitute != null)
            {
                company.UploadMemberOfTheInstitute = await fileManager.InsertFiles(UploadMemberOfTheInstitute, "image/Document");
            }


            if (ModelState.IsValid)
            {
                _context.Add(company);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));

                //ViewData["CarId"] = new SelectList(_context.Cars, "Id", "Id", company.Car.CarType.Name);
                ViewData["CompanyTypeId"]   = new SelectList(_context.CompanyTypes, "Id", "Id", company.CompanyType.Id);
                ViewData["LicenseId"]       = new SelectList(_context.Licenses, "Id", "Id", company.License.LicenseType.Name);
                ViewData["OwnershipTypeId"] = new SelectList(_context.OwnershipType, "Id", "Id", company.OwnershipType.Id);
            }

            return(View(company));
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] LicenseType licenseType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(licenseType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(licenseType));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("Id,Name")] ManufacturingGroup manufacturingGroup)
        {
            if (ModelState.IsValid)
            {
                _context.Add(manufacturingGroup);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(manufacturingGroup));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Family,FatherName,NationalCode,IDNumber,BirthDate,DegreeEducation,Tel,Fax,Email,Post,WorkExperience,TheSignatory,CustomerTypeId,UserId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerTypeId"] = new SelectList(_context.CustomerTypes, "Id", "Id", customer.CustomerTypeId);
            return(View(customer));
        }
        public async Task <IActionResult> Create([Bind("Id,StartDate,EndDate,UploadLinces,LicenseTypeId,UserId")] License license)
        {
            if (ModelState.IsValid)
            {
                _context.Add(license);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LicenseTypeId"] = new SelectList(_context.LicenseTypes, "Id", "Id", license.LicenseTypeId);
            return(View(license));
        }
        public async Task <IActionResult> Create([Bind("Id,Year,Amount,ProductId,UserId")] ProductionRate productionRate)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productionRate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Id", productionRate.ProductId);
            return(View(productionRate));
        }
        /// <summary>
        /// ベンダリストアップデート
        /// </summary>
        /// <returns></returns>
        public async Task UpdateVendors()
        {
            //完全に判定するならばMA-L,MA-M,MA-Sをそれぞれ更新する必要がある
            //MA-SをMA-Mにも登録
            //MA-MをMA-Lにも登録する?
            this.IsBusy = true;
            var hc  = new HttpClient();
            var res = await hc.GetAsync(this._macAddressUrl, HttpCompletionOption.ResponseHeadersRead);

            //全体のファイルサイズ
            var fullsize = (long)res.Content.Headers.ContentLength;

            using (var httpStream = await res.Content.ReadAsStreamAsync())
                using (var sr = new StreamReader(httpStream))
                    using (var csvReader = new CsvReader(sr))
                        using (var dataContext = new VendorDbContext(this._vendorDbPath)) {
                            using (var transaction = dataContext.Database.BeginTransaction()) {
                                // ベンダIDが被ってるものがある。詳細は不明なため、2件目以降はスキップする。
                                // 登録済みのベンダIDを退避しておく。
                                var insertedAssignments = new List <string>();

                                // 現在データ全件DELETE
                                await dataContext.Database.ExecuteSqlCommandAsync("DELETE FROM Vendors;");

                                csvReader.Configuration.HasHeaderRecord = true;
                                csvReader.Configuration.RegisterClassMap <VendorMapper>();

                                await Task.Run(() => {
                                    foreach (var vendor in csvReader.GetRecords <Vendor>())
                                    {
                                        if (insertedAssignments.All(x => x != vendor.Assignment))
                                        {
                                            dataContext.Vendors.Add(vendor);
                                            insertedAssignments.Add(vendor.Assignment);
                                        }
                                        this.ProgressRate = (int)(((double)csvReader.Context.CharPosition / fullsize) * 100);
                                    }
                                });

                                await dataContext.SaveChangesAsync();

                                transaction.Commit();
                            }
                            this.IsBusy = false;
                        }
        }
Beispiel #10
0
        public async Task CreateSchedule([FromBody] Schedule schedule)
        {
            await db.Schedules.AddAsync(schedule);

            await db.SaveChangesAsync();
        }