public async Task <JObject> GetAsync(int id) { var serviceQuery = _contentManagementContext .MasterDataKeyValues.Where(sr => sr.Id == id && sr.TypeId == (int)EntityIdentity.Service).FutureFirstOrDefault(); var maxIdQuery = _contentManagementContext.MasterDataKeyValues.OrderByDescending(md => md.Id).FutureFirstOrDefault(); var service = serviceQuery.Value; var maxId = maxIdQuery.Value; if (service == null) { return(null); } AuthorizeManager.CheckViewAccess(service); if (!AuthorizeManager.IsAuthorizeToViewSourceCodeOfService(service.Id)) { throw new UnauthorizedAccessException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidGrant)); } return(await ConvertToJsonAsync(service, maxId.Id + 1)); }
public string GetChangeFromSourceControl(int changeId, int codeId) { if (!AuthorizeManager.IsAuthorizeToViewSourceCodeOfService(codeId)) { throw new UnauthorizedAccessException(LanguageManager.ToAsErrorMessage(ExceptionKey.InvalidGrant)); } var change = _sourceControl.GeChangeById(changeId, Config.ServicesSourceCodePath); if (change == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.ChangeNotFound)); } if (change.Code == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.ChangeHasNoCode)); } return(change.Code); }