Exemple #1
0
        public async Task <IActionResult> PutMainHistory(string id, MainHistory mainHistory)
        {
            if (id != mainHistory.Anchor)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> Edit(string id, [Bind("Anchor,Idindivid,IdZoo,Data")] MainHistory mainHistory)
        {
            if (id != mainHistory.Anchor)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mainHistory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MainHistoryExists(mainHistory.Anchor))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mainHistory));
        }
Exemple #3
0
        public static void Serializer()
        {
            MainHistory historyEntity = new MainHistory();

            XmlSerializer formatter = new XmlSerializer(typeof(List <CodingHistory>));

            using (FileStream fs = new FileStream("history.xml", FileMode.OpenOrCreate))
            {
                formatter.Serialize(fs, historyEntity.CodingHistorys);
            }
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("Anchor,Idindivid,IdZoo,Data")] MainHistory mainHistory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mainHistory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mainHistory));
        }
Exemple #5
0
        public void Delete()
        {
            // 排列
            HistoryController controller = new HistoryController();

            MainHistory value = new MainHistory();
            // 作用
            HttpResponseMessage result = controller.Delete(value);

            // 判斷提示
            Assert.AreEqual(15, result);
        }
Exemple #6
0
        public HttpResponseMessage Post([FromBody] MainHistory value)
        {
            if (value.Date == DateTime.MinValue)
            {
                value.Date = Function.GetTime();
            }
            ;

            var response = (int)DapperHelper.InsertSQL <MainHistory>(connectionString, TableName, value);

            value.SeqNo = response;
            return(Request.CreateResponse(HttpStatusCode.OK, value));
        }
Exemple #7
0
        public void Get()
        {
            // 排列
            HistoryController controller = new HistoryController();

            // 作用
            HttpResponseMessage result = controller.Get();

            MainHistory value = new MainHistory();

            // 判斷提示
            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.TryGetContentValue <MainHistory>(out value));
        }
Exemple #8
0
        public async Task <ActionResult <MainHistory> > PostMainHistory(MainHistory mainHistory)
        {
            _context.MainHistory.Add(mainHistory);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (MainHistoryExists(mainHistory.Anchor))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetMainHistory", new { id = mainHistory.Anchor }, mainHistory));
        }
Exemple #9
0
        public HttpResponseMessage Put([FromBody] MainHistory value)
        {
            var response = DapperHelper.UpdateSQL <MainHistory>(connectionString, TableName, value);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemple #10
0
        public HttpResponseMessage Delete([FromBody] MainHistory value)
        {
            var response = DapperHelper.DeleteSQL(connectionString, TableName, value.SeqNo);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }