Esempio n. 1
0
        public CustomMiniMenuBlock(Dish d)
        {
            InitializeComponent();
            dish = d;

            dishNameTextBlock.Text = dish.Name;
            dishImage.Source       = ImageConverter.Base64ToImage(dish.Image);

            IncreaseDishesCount();
        }
Esempio n. 2
0
        public CustomMenuBlock(Dish dish, bool isAdmin, Thickness margin)
        {
            InitializeComponent();
            this.dish    = dish;
            this.isAdmin = isAdmin;
            this.Margin  = margin;

            dishImage.Source              = ImageConverter.Base64ToImage(dish.Image);
            titleTextBlock.Text           = dish.Name;
            ingridientsListTextBlock.Text = dish.Ingridients;
            costTextBlock.Text            = dish.Cost + "руб.";
            CompositionTextBlock.Text     = dish.Composition;

            this.Width  = 250;
            this.Height = 300;
        }
        public async Task <TakeAttendanceByImageResponse> TakeAttendanceByImage(TakeAttendanceByImageRequest request)
        {
            TakeAttendanceByImageResponse response = new TakeAttendanceByImageResponse();
            var rootImages        = new List <RootImage>();
            var locationImagePath = Path.Combine(HttpRuntime.AppDomainAppPath, Constants.Config.AttendanceImagePath, request.Date.ToString("yyyyMMdd"), request.ClassId, request.SlotId.ToString());

            ImageConverter.CreateDirectory(locationImagePath);
            int numberOfImage = 1;
            await Task.Run(async() =>
            {
                foreach (var imageUrl in request.ImageUrls)
                {
                    var image = await GetImages(imageUrl);
                    rootImages.Add(image);
                    //save image to folder
                    ImageConverter.Base64ToImage(Path.Combine(locationImagePath, numberOfImage + ".jpg"), imageUrl);
                    numberOfImage++;
                }
            });

            var listCandidateId = new List <string>();

            try
            {
                foreach (var rootImage in rootImages)
                {
                    foreach (var image in rootImage.Images)
                    {
                        if (image.Candidates != null && image.Transaction.Status.Equals(Constants.KairosApi.TransactionSuccess))
                        {
                            var firstCandidate = image.Candidates.OrderByDescending(c => c.Confidence).First();
                            listCandidateId.Add(firstCandidate.SubjectId);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            listCandidateId = listCandidateId.Distinct().ToList();
            var studentList = (from sd in _context.Schedules
                               where sd.TeacherId == request.UserId &&
                               sd.Date == request.Date &&
                               sd.SlotId == request.SlotId
                               select sd).ToList();
            List <StudentAttendance> students = new List <StudentAttendance>();

            foreach (var student in studentList)
            {
                if (listCandidateId.Any(x => x.Equals(student.StudentId)))
                {
                    student.AttendanceStatus = Constants.AttendanceStatus.Presented;
                }
                else
                {
                    student.AttendanceStatus = Constants.AttendanceStatus.Absent;
                }
                var studentAttendance = (from st in _context.Students
                                         where st.StudentId == student.StudentId
                                         select new StudentAttendance()
                {
                    StudentId = st.StudentId,
                    FullName = st.FullName,
                    Email = st.Email,
                    AttendanceStatus = student.AttendanceStatus
                }).First();
                students.Add(studentAttendance);
            }
            _context.SaveChanges();
            response.Students = students;
            return(response);
        }