public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,UserId,Date,ProjectId")] WebApplication1.Models.Task task)
        {
            if (id != task.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(task);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskExists(task.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Redirect("/ProjectTasks/Index"));
            }

            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "UserName", task.UserId);
            ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Name", task.ProjectId);
            return(View(task));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Description,UserId,Date,ProjectId")] WebApplication1.Models.Task task)
        {
            if (ModelState.IsValid)
            {
                _context.Add(task);
                await _context.SaveChangesAsync();

                return(Redirect("/ProjectTasks/Index"));
            }
            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "UserName", task.UserId);
            ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Name", task.ProjectId);
            return(View(task));
        }
Пример #3
0
        public string Update(Task model)
        {
            var todoContext = new ToDoDbContext();//create instance dbcontext

            try
            {
                todoContext.Update(model); //update model to dataabse
                todoContext.SaveChanges(); //commit save change
            }
            catch (Exception e)
            {
                return("Failed when update data"); //return result
            }
            return("Successfully update data");    //return result
        }
Пример #4
0
        public string Add(Task model)
        {
            var todoContext = new ToDoDbContext();//create instance dbcontext

            try
            {
                todoContext.Add(model);    //save model to database
                todoContext.SaveChanges(); //commit save change
            }
            catch (Exception e)
            {
                return("Failed add data");   //return result
            }
            return("Successfully add data"); //return result
        }
        private int gett_ssim_sonucu()
        {
            try
            {
                Double en_buyuk   = 0;
                int    en_buyuk_i = -1;
                string adres      = HttpContext.Current.Server.MapPath("~/hayvanlar/");
                //adres = adres.Replace("bin\\Debug\\", string.Empty);
                string[] files = Directory.GetFiles(adres);
                task            = new Task();
                task.TaskGroups = new List <TaskGroup>();



                foreach (var file in files)
                {
                    TaskGroup g6 = new TaskGroup();
                    g6.GroupName             = Path.GetFileName(file);
                    g6.OriginalImageFileName = file;
                    g6.TaskItems             = new List <TaskItem>();
                    task.TaskGroups.Add(g6);
                }
                for (int i = 0; i < task.TaskGroups.Count; i++)
                {
                    TaskGroup g2 = task.TaskGroups[i];

                    Bitmap newOrBitmap = new Bitmap(200, 200);
                    Bitmap newPrBitmap = new Bitmap(200, 200);

                    Graphics graphicOrImage = Graphics.FromImage(newOrBitmap);
                    Graphics graphicPrImage = Graphics.FromImage(newPrBitmap);
                    graphicOrImage.DrawImage(originalBitMap, 0, 0, 200, 200);

                    Bitmap originalBitMap2 = new Bitmap(g2.OriginalImageFileName);
                    originalBitMap2 = makeGray(originalBitMap2);

                    graphicPrImage.DrawImage(originalBitMap2, 0, 0, 200, 200);


                    List <Bitmap> orBlockArray = new List <Bitmap>();
                    List <Bitmap> prBlockArray = new List <Bitmap>();
                    for (int k = 0; k < 200 / 8; k++)
                    {
                        for (int j = 0; j < 200 / 8; j++)
                        {
                            Bitmap orBlock = new Bitmap(8, 8);
                            orBlock = Cut(newOrBitmap, k * 8, j * 8, 8, 8);
                            orBlockArray.Add(orBlock);
                            Bitmap prBlock = new Bitmap(8, 8);
                            prBlock = Cut(newPrBitmap, k * 8, j * 8, 8, 8);
                            prBlockArray.Add(prBlock);
                        }
                    }
                    double SSIM = GetSSIM(orBlockArray, prBlockArray);
                    if (SSIM > en_buyuk)
                    {
                        en_buyuk   = SSIM;
                        en_buyuk_i = i;
                    }

                    dizi[i] = SSIM;
                }
                return(en_buyuk_i);
            }
            catch (Exception ex)
            {
                string error = ex.ToString();
                return(-1);
            }
        }