Example #1
0
        public async Task <ActionResult <HelthStatus> > PostHelthStatus(HelthStatus helthStatus)
        {
            _context.HelthStatus.Add(helthStatus);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetHelthStatus", new { id = helthStatus.IdHealth }, helthStatus));
        }
Example #2
0
        public async Task <IActionResult> PutHelthStatus(short id, HelthStatus helthStatus)
        {
            if (id != helthStatus.IdHealth)
            {
                return(BadRequest());
            }

            _context.Entry(helthStatus).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HelthStatusExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
        public string ExportCustomer()
        {
            string rootFolder = @"C:\Users\Yulia\Desktop\VeloAPI\resours\Export\";
            string fileName   = $"ExportUsers{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";

            FileInfo file = new FileInfo(Path.Combine(rootFolder, fileName));

            using (ExcelPackage package = new ExcelPackage(file))
            {
                IList <UserInfo> customerList = _context.UserInfo.ToList();
                package.Workbook.Properties.Author = "VeloNSKAPI";
                ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Пользователи");
                worksheet.Cells[1, 1].Value           = "Участники";
                worksheet.Cells[1, 1].Style.Font.Size = 14;
                worksheet.Cells[1, 1].Style.Font.Bold = true;
                worksheet.Cells["A1:I1"].Merge        = true;

                int totalRows = customerList.Count();

                worksheet.Cells[2, 1].Value = "Login";
                worksheet.Cells[2, 2].Value = "Роль";
                worksheet.Cells[2, 3].Value = "Фамилия";
                worksheet.Cells[2, 4].Value = "E-mail";
                worksheet.Cells[2, 5].Value = "Имя";
                worksheet.Cells[2, 6].Value = "Отчество";
                worksheet.Cells[2, 7].Value = "Возраст";
                worksheet.Cells[2, 8].Value = "Пол";
                worksheet.Cells[2, 9].Value = "Статус здоровья";
                for (int row = 1; row <= totalRows + 2; row++)
                {
                    for (int column = 1; column <= 9; column++)
                    {
                        worksheet.Column(column).Style.HorizontalAlignment     = ExcelHorizontalAlignment.Center;
                        worksheet.Column(column).Style.VerticalAlignment       = ExcelVerticalAlignment.Center;
                        worksheet.Cells[row, column].Style.Border.Top.Style    = ExcelBorderStyle.Medium;
                        worksheet.Cells[row, column].Style.Border.Right.Style  = ExcelBorderStyle.Medium;
                        worksheet.Cells[row, column].Style.Border.Bottom.Style = ExcelBorderStyle.Medium;
                        if (row % 2 == 0)
                        {
                            worksheet.Cells[row, column].Style.Fill.PatternType = ExcelFillStyle.Solid;
                            worksheet.Cells[row, column].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.BurlyWood);
                        }
                    }
                }
                int    i   = 0;
                string pol = "";
                for (int row = 3; row <= totalRows + 2; row++)
                {
                    worksheet.Cells[row, 1].Value = customerList[i].Login;
                    worksheet.Cells[row, 2].Value = customerList[i].Rol;
                    worksheet.Cells[row, 3].Value = customerList[i].Fam;
                    worksheet.Cells[row, 4].Value = customerList[i].Email;
                    worksheet.Cells[row, 5].Value = customerList[i].Name;
                    worksheet.Cells[row, 6].Value = customerList[i].Patronimic;
                    worksheet.Cells[row, 7].Value = customerList[i].Years;
                    if (customerList[i].Isman)
                    {
                        pol = "Мужской";
                    }
                    else
                    {
                        pol = "Женский";
                    }
                    worksheet.Cells[row, 8].Value = pol;
                    HelthStatus person = _context.HelthStatus.FirstOrDefault(x => x.IdHealth == customerList[i].IdHelth);
                    worksheet.Cells[row, 9].Value = person.NameHealth;
                    i++;
                }
                worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();

                package.Save();
            }
            return("http://90.189.158.10/Export/" + fileName);
        }