public void TestUpdateClientRecord()
        {
            RestaurantSeeder.SeedCountries();
            var bo      = new StaffRecordBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

            item.BeginDate = DateTime.Parse("2020/05/05");
            var resUpdate  = bo.Update(item);
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted);

            Assert.IsTrue(resUpdate.Success && resNotList.First().BeginDate == DateTime.Parse("2020/05/05"));
        }
예제 #2
0
        public void TestUpdateStaffRecord()
        {
            RestaurantSeeder.Seed();
            var bo      = new StaffRecordBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();
            var now     = DateTime.Now;

            item.BeginDate = now;
            var resUpdate = bo.Update(item);

            resList = bo.ListNonDeleted();
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().BeginDate == now);
        }
예제 #3
0
        public ActionResult Update([FromBody] StaffRecordViewModel sr)
        {
            var currentResult = _bo.Read(sr.Id);

            if (!currentResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var current = currentResult.Result;

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

            if (current.BeginDate == sr.BeginDate && current.EndDate == sr.EndDate &&
                current.RestaurantId == sr.RestaurantId && current.PersonId == sr.PersonId)
            {
                return(new ObjectResult(HttpStatusCode.NotModified));
            }

            if (current.BeginDate != sr.BeginDate)
            {
                current.BeginDate = sr.BeginDate;
            }
            if (current.EndDate != sr.EndDate)
            {
                current.EndDate = sr.EndDate;
            }
            if (current.PersonId != sr.PersonId)
            {
                current.PersonId = sr.PersonId;
            }
            if (current.RestaurantId != sr.RestaurantId)
            {
                current.RestaurantId = sr.RestaurantId;
            }
            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
예제 #4
0
        public void TestUpdateStaffRecord()
        {
            ContextSeeders.Seed();
            var srbo    = new StaffRecordBusinessObject();
            var resList = srbo.List();
            var item    = resList.Result.FirstOrDefault();

            var pbo  = new PersonBusinessObject();
            var rbo  = new RestaurantBusinessObject();
            var lubo = new LennyouseUserBusinessObject();

            var _lennyouseUser = new LennyouseUser(Guid.NewGuid());

            lubo.Create(_lennyouseUser);

            var _person = new Person(3654324444, 0000000, "Marco", "Figueirnha", DateTime.UtcNow, _lennyouseUser.Id);

            pbo.Create(_person);

            var _restaurant = new Restaurant("Tasca da Lua", "Bairro Alto 2", "12h", "00h", "Mondays", 7);

            rbo.Create(_restaurant);


            var _newStaffRecord = new StaffRecord(DateTime.UtcNow, DateTime.UtcNow, _person.Id, _restaurant.Id);

            item.BeginDate    = _newStaffRecord.BeginDate;
            item.EndDate      = _newStaffRecord.EndDate;
            item.PersonId     = _newStaffRecord.PersonId;
            item.RestaurantId = _newStaffRecord.RestaurantId;

            var resUpdate = srbo.Update(item);

            resList = srbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().BeginDate == _newStaffRecord.BeginDate &&
                          resList.Result.First().EndDate == _newStaffRecord.EndDate &&
                          resList.Result.First().PersonId == _newStaffRecord.PersonId &&
                          resList.Result.First().RestaurantId == _newStaffRecord.RestaurantId
                          );
        }
        public ActionResult Update([FromBody] StaffRecordViewModel sr)
        {
            var currentResult = _bo.Read(sr.Id);

            if (!currentResult.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            var current = currentResult.Result;

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

            if (current.BeginDate == sr.BeginDate && current.EndDate == sr.EndDate)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            if (current.BeginDate != sr.BeginDate)
            {
                current.BeginDate = sr.BeginDate;
            }
            if (current.EndDate != sr.EndDate)
            {
                current.EndDate = sr.EndDate;
            }

            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
예제 #6
0
        public ActionResult Update([FromBody] StaffRecordViewModel rt)
        {
            var currentResult = _bo.Read(rt.Id);

            if (!currentResult.Success)
            {
                return(InternalServerError());
            }
            var current = currentResult.Result;

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

            if (current.BeginDate == rt.BeginDate && current.EndDate == rt.EndDate)
            {
                return(InternalServerError());
            }

            if (current.BeginDate != rt.BeginDate)
            {
                current.BeginDate = rt.BeginDate;
            }
            if (current.EndDate != rt.EndDate)
            {
                current.EndDate = rt.EndDate;
            }

            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(InternalServerError());
            }
            return(Ok());
        }