Ejemplo n.º 1
0
        public async Task <IActionResult> UpdateImgOfCategory([FromBody] PictureUpdate pictureUpdate)
        {
            try
            {
                if (pictureUpdate.Picture.Length > 0)
                {
                    var category = await _uow.Repository <Category>()
                                   .GetAll().FirstOrDefaultAsync(x => x.CategoryId == pictureUpdate.CategoryId);

                    if (category is not null)
                    {
                        _mapper.Map(pictureUpdate, category);
                        await _uow.SaveChangesAsync();

                        return(Ok(new { info = "The picture of category has been updated." }));
                    }

                    return(BadRequest(new
                    {
                        error = "The selected category is not available."
                    }));
                }

                return(BadRequest(new
                {
                    error = $"The picture name field cannot be empty. The picture was not updated."
                }));
            }
            catch (Exception e)
            {
                return(Problem(e.Message, null, null, e.Source));
            }
        }
Ejemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string[]     list = new string[9];
            ListViewItem item;
            bool         Updated = false;
            var          term    = "";

            if (Term != "خودکار")
            {
                term = "AND FoodTermName = '" + Term + "'";
            }
            cmd = new SqlCommand("SELECT * FROM [Framework].[Rst].[Monitoring] WHERE OnlineUserID = 123456789 and ResturantName = '" + Rest + "' " + term + " AND ServeDate = '" + selecteddate + "' and ID > " + ID + " ORDER BY ID ASC  OFFSET 0 ROWS fetch next 100 rows only", con);
            using (var data = cmd.ExecuteReader())
            {
                while (true)
                {
                    if (data.Read())
                    {
                        try
                        {
                            Updated  = true;
                            list[1]  = data.safeGetString(data.GetOrdinal("PersonID"));
                            list[2]  = data.safeGetString(data.GetOrdinal("PersonName"));
                            list[3]  = data.safeGetString(data.GetOrdinal("DeptName"));
                            list[4]  = data.safeGetString(data.GetOrdinal("FoodName"));
                            list[5]  = data.safeGetString(data.GetOrdinal("Time"));
                            list[6]  = data.safeGetString(data.GetOrdinal("FoodTermName"));
                            list[7]  = data.safeGetString(data.GetOrdinal("ResturantName"));
                            list[8]  = data.safeGetString(data.GetOrdinal("StrError"));
                            lastTerm = data.safeGetString(data.GetOrdinal("FoodTermName"));
                            ID       = data.GetInt32(data.GetOrdinal("ID"));
                            if (!data.IsDBNull(data.GetOrdinal("FishNo")))
                            {
                                FishNo  = data.GetInt32(data.GetOrdinal("FishNo"));
                                list[0] = FishNo.ToString();
                            }
                            else
                            {
                                list[0] = "-";
                            }
                        }
                        catch
                        {
                            continue;
                        }
                        finally
                        {
                            item = new ListViewItem(list);
                            listView1.Items.Insert(0, item);
                            pictureBox1.Image = null;
                            PictureUpdate.Stop();
                            PictureUpdate.Start();
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            var total = listView1.Items.Count;

            for (int i = total; i > 2000; i--)
            {
                listView1.Items.RemoveAt(i - 1);
            }
            if (Updated)
            {
                FishNum.Text    = list[0];
                PersonID.Text   = list[1];
                PersonName.Text = list[2];
                DeptName.Text   = list[3];
                FoodName.Text   = list[4];
                Time.Text       = list[5];
                FoodTerm.Text   = list[6];
                RestName.Text   = list[7];
                StrError.Text   = list[8];
                if (list[8] != "مجاز به استفاده")
                {
                    StrError.ForeColor = Color.Red;
                }
                else
                {
                    StrError.ForeColor = Color.MediumSeaGreen;
                }
            }
        }