Esempio n. 1
0
        public HttpResponseMessage UpdateTime([FromBody] TimeDTO time)
        {
            if (time != null)
            {
                DTOToEntity dte    = new DTOToEntity();
                var         entity = dte.TimeDTOToEntity(time);

                repo.UpdateTime(entity);

                return(Request.CreateResponse(HttpStatusCode.OK, "Time changed successfully."));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "An error Occured"));
            }
        }
        public void TimeDTOToEntityValid()
        {
            DTOToEntity dte = new DTOToEntity();

            TimeDTO expected = new TimeDTO {
                Id = 1, Project_Id = 1, Date = DateTime.Now, TimeStart = new DateTime(2017, 08, 26, 08, 00, 00), TimeEnd = new DateTime(2017, 08, 26, 10, 00, 00), IsInvoiced = false, Description = "Test description"
            };

            var actual = dte.TimeDTOToEntity(expected);

            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Project_Id, actual.Project_Id);
            Assert.AreEqual(expected.Description, actual.Description);
            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.TimeStart, actual.TimeStart);
            Assert.AreEqual(expected.TimeEnd, actual.TimeEnd);
            Assert.AreEqual(expected.IsInvoiced, actual.IsInvoiced);
        }
Esempio n. 3
0
        public HttpResponseMessage AddTime([FromBody] TimeDTO newTime)
        {
            if (newTime != null)
            {
                DTOToEntity dte = new DTOToEntity();

                newTime.Date       = DateTime.Now;
                newTime.IsInvoiced = false;
                var entity = dte.TimeDTOToEntity(newTime);

                repo.AddTime(entity);
                return(Request.CreateResponse(HttpStatusCode.OK, "Time uploaded successfully."));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "An error Occured"));
            }
        }