Example #1
0
        public IHttpActionResult Postincident(incident incident)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.incidents.Add(incident);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (incidentExists(incident.unid))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = incident.unid }, incident));
        }
Example #2
0
        public IHttpActionResult Putincident(Guid id, incident incident)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != incident.unid)
            {
                return(BadRequest());
            }

            db.Entry(incident).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!incidentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public IHttpActionResult Getincident(Guid id)
        {
            incident incident = db.incidents.Find(id);

            if (incident == null)
            {
                return(NotFound());
            }

            return(Ok(incident));
        }
Example #4
0
        public IHttpActionResult Deleteincident(Guid id)
        {
            incident incident = db.incidents.Find(id);

            if (incident == null)
            {
                return(NotFound());
            }

            db.incidents.Remove(incident);
            db.SaveChanges();

            return(Ok(incident));
        }
Example #5
0
        public void StoredProcedureTest02()
        {
            var operatorIDString = "08921908-EBA0-4A20-B2C7-703A05569338";
            var startDateString  = "02 jul 2018";
            var endDateString    = "03 jul 2018";

            DateTime.TryParse(startDateString, out var startDate);
            DateTime.TryParse(endDateString, out var endDate);
            Guid.TryParse(operatorIDString, out var operatorId);

            TopDesk577Entities db = new TopDesk577Entities();
            var results           = db.UTVF_IncidentsMovedToOperator(operatorId, startDate, endDate);

            Assert.IsNotNull(results, "Stored Proceducre returned no results");
            Assert.IsTrue(results.Any(), "Doesn't have any records");

            var incident = results.FirstOrDefault();  // Incident number.

            Assert.IsNotNull(incident, "Incident is null");
            Assert.IsFalse(string.IsNullOrEmpty(incident.Incident), "Incident text is empty");

            incident incidentItem = db.incidents.Where(x => x.naam == incident.Incident).FirstOrDefault();

            Assert.IsNotNull(incidentItem, "Stored Proceducre returned no results");
            Assert.IsTrue(incidentItem.naam == incident.Incident, "Incident Records don't match");

            var results2 = db.UTVF_IncidentOperatorMovements(incident.Incident);

            Assert.IsNotNull(results2, "Stored Proceducre returned no results");
            Assert.IsTrue(results2.Any(), "Doesn't have any records");

            var incident2 = results2.FirstOrDefault();

            Assert.IsNotNull(incident.Incident, "Incident is null");
            Assert.IsFalse(string.IsNullOrEmpty(incident.Incident), "Incident text is empty");

            var currentDate = new DateTime();

            results2.ToList().ForEach(item =>
            {
                Assert.IsTrue(item.Move_Date != null, "Move date is null");
                Assert.IsTrue(item.Move_Date > currentDate, "Move Date is not is sequencial order :" + currentDate.ToString() + " " + item.Move_Date.ToString() + " Row " + item.RowNumber);
                currentDate = (DateTime)item.Move_Date;
            });

            JSON_FileExport.WriteFile("StoredProcedureTest02", results2, results2.Count(), "USP_Functions");
        }