private static void AddEntitlementsToModel(decimal clientId, EntitlementsModel model, List <EEntitlement> entitlements)
        {
            List <ELicenseType>         licTypes  = EntitlementsProvider.GetLicenseTypes();
            List <EditEntitlementModel> entModels = new List <EditEntitlementModel>();

            foreach (EEntitlement dbEnt in entitlements)
            {
                var entModel = new EditEntitlementModel()
                {
                    LicenseTypeName = licTypes.FirstOrDefault(l => l.Id == dbEnt.LicenseTypeId).Name
                };
                entModels.Add(entModel.LoadEntitlement(dbEnt));
                entModel.Projectname = ProjectsProvider.GetProject(entModel.ProjectId).ProjectName;
            }
            model.Entitlemens        = entModels;
            model.ClientId           = clientId;
            model.ClientInternalName = ClientsProvider.GetClient(clientId).Name;
        }
        public ActionResult EditEntitlement(decimal entitlementId)
        {
            CheckUserAuthorization();
            if (entitlementId < 1)
            {
                RedirectToAction("Index", "Entitlements");
            }
            decimal currentUser = UserStateManager.GetUserIdFromCookies(Request);
            var     entitlement = EntitlementsProvider.GetEntitlement(entitlementId);

            if (entitlement == null)
            {
                RedirectToAction("Index", "Entitlements");
            }
            if (entitlement.UserCreatorId == currentUser)//TODO check by project members
            {
                EditEntitlementModel model = new EditEntitlementModel();
                model.LoadEntitlement(entitlement);
                LoadThirdElementsData(model);
                return(View("EditEntitlement", model));
            }
            return(RedirectToAction("Index", "Entitlements"));
        }