Exemple #1
0
        public IActionResult PutQuota(Guid?id, Quota quota)
        {
            if (id != quota.Id)
            {
                return(BadRequest());
            }
            // check if any changes are in hours or in dates to  do changes in requests entries
            Quota quotaOld = uow.QuotaRepo.GetById(id);

            if (quotaOld == null)
            {
                return(NotFound());
            }
            if (quotaOld.RemainingHours != quota.RemainingHours)
            {
                return(BadRequest());
            }

            quota.RemainingHours = quota.OriginalHours; //! important
            uow.QuotaRepo.Put(quota, quota.Id);
            uow.SaveChanges();

            if (quotaOld.StartDateTime != quota.StartDateTime ||
                quotaOld.EndDateTime != quota.EndDateTime ||
                quotaOld.OriginalHours != quota.OriginalHours)       // Either or both datetimes are different
                                                                     //Validate and re-allocate all requests related to this Quota and other waitlisted requests which fit in this date range in the same team
            {
                quotaService.ReDoAllocate(quotaOld, quota);
            }
            return(Ok());
        }